Skip to content

Commit

Permalink
merge dev (#3)
Browse files Browse the repository at this point in the history
fix: 修复商城截图部分图片未加载
chore: 战绩季卡显示名称显示真实的大小写,而不是用户输入
  • Loading branch information
fllesser authored Jan 10, 2025
1 parent 5608f1e commit b66dc09
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
25 changes: 16 additions & 9 deletions nonebot_plugin_fortnite/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,22 @@ async def screenshot_shop_img() -> Path:
# page.on('requestfailed', lambda request: logger.warning(f'Request failed: {request.url}'))
await page.add_style_tag(content='* { transition: none !important; animation: none !important; }')
await page.goto(url)
# 模拟滚动到页面底部
for _ in range(10):
await page.evaluate("""() => {
window.scrollBy(0, document.body.scrollHeight);
}""")
await asyncio.sleep(2) # 等待2秒以加载内容

await page.wait_for_load_state('networkidle', timeout=100000)
# await page.wait_for_load_state('load') # 等待页面加载完毕

async def wait_for_load():
await page.wait_for_load_state('networkidle', timeout=60000)

async def scroll_page():
for _ in range(20):
await page.evaluate("""() => {
window.scrollBy(0, document.body.scrollHeight / 20);
}""")
await asyncio.sleep(1) # 等待1秒以加载内容

await asyncio.gather(
wait_for_load(),
scroll_page()
)

await page.screenshot(path=shop_file, full_page=True)
return shop_file
finally:
Expand Down
4 changes: 2 additions & 2 deletions nonebot_plugin_fortnite/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ async def get_level(name: str, time_window: str) -> int:
time_window = TimeWindow.LIFETIME if time_window.startswith("生涯") else TimeWindow.SEASON
stats = await get_stats(name, time_window)
bp = stats.battle_pass
return f'等级: {bp.level} 下一级进度: {bp.progress}%'
return f'{stats.user.name}: Lv{bp.level} | {bp.progress}% to Lv{bp.level + 1}'

@exception_handler()
async def get_stats_image(name: str, time_window: str) -> Path:
time_window = TimeWindow.LIFETIME if time_window.startswith("生涯") else TimeWindow.SEASON
stats = await get_stats(name, time_window, StatsImageType.ALL)
return await get_stats_img_by_url(stats.image.url, name)
return await get_stats_img_by_url(stats.image.url, stats.user.name)


font_path: Path | None = None
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot-plugin-fortnite"
version = "0.1.1"
version = "0.1.2"
description = "堡垒之夜插件"
authors = ["fllesser <fllessive@gmail.com>"]
readme = "README.md"
Expand All @@ -12,14 +12,14 @@ keywords = ["nonebot", "nonebot2"]
[tool.poetry.dependencies]
python = "^3.10"
httpx = "^0.27.2"
fortnite-api = "^3.2.1"
pillow = "^10.4.0"
playwright = "^1.4.9.1"
nonebot2 = "^2.4.0"
nonebot-plugin-uninfo = "^0.6.5"
nonebot-plugin-alconna = "^0.54.2"
nonebot-plugin-localstore = "^0.7.3"
nonebot-plugin-apscheduler = "^0.5.0"
fortnite-api = {version = "^3.2.1", extras = ["speed"]}

[tool.poetry.group.test.dependencies]
nb-cli = "^1.4.2"
Expand Down

0 comments on commit b66dc09

Please sign in to comment.