Compare commits

...

6 Commits
1.1.0 ... 1.1.3

Author SHA1 Message Date
5bcecc0623 🔖 1.1.3 2024-05-10 12:11:19 +08:00
9cf048fce4 新增 更新模板 指令 2024-05-10 12:10:45 +08:00
aff2fa120a 🔖 1.1.2 2024-05-10 11:49:05 +08:00
1c057661c2 🐛 防止历史记录一条都没有的数组越界 2024-05-10 11:48:47 +08:00
83bcd14012 🔖 1.1.1 2024-05-10 11:30:08 +08:00
70f53a2c76 🐛 修复 init_templates 和 mount assets 的运行顺序问题 2024-05-10 11:29:46 +08:00
4 changed files with 27 additions and 7 deletions

View File

@@ -241,7 +241,13 @@ class Processor(ProcessorMeta):
if extra is not None:
historical_data = list(historical_data)
historical_data.append(extra)
if not historical_data:
return [
TETRIOInfo.TetraLeagueHistory.Data(record_at=today - forward, tr=user_info.data.user.league.rating),
TETRIOInfo.TetraLeagueHistory.Data(
record_at=today.replace(microsecond=1000), tr=user_info.data.user.league.rating
),
]
histories = [
TETRIOInfo.TetraLeagueHistory.Data(
record_at=i.processed_data.user_info.cache.cached_at.astimezone(ZoneInfo('Asia/Shanghai')),

View File

@@ -6,6 +6,7 @@ from fastapi import FastAPI, status
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from nonebot import get_app, get_driver
from nonebot.log import logger
from nonebot_plugin_localstore import get_cache_dir # type: ignore[import-untyped]
from pydantic import IPvAnyAddress
@@ -39,11 +40,14 @@ class HostPage:
self.pages.pop(self.page_hash, None)
app.mount(
'/host/assets',
StaticFiles(directory=templates_dir / 'assets'),
name='assets',
)
@driver.on_startup
def _():
app.mount(
'/host/assets',
StaticFiles(directory=templates_dir / 'assets'),
name='assets',
)
logger.success('assets mounted')
@app.get('/host/{page_hash}.html', status_code=status.HTTP_200_OK)

View File

@@ -3,12 +3,16 @@ from shutil import rmtree
from nonebot import get_driver
from nonebot.log import logger
from nonebot.permission import SUPERUSER
from nonebot_plugin_alconna import on_alconna
from nonebot_plugin_localstore import get_data_dir # type: ignore[import-untyped]
driver = get_driver()
templates_dir = get_data_dir('nonebot_plugin_tetris_stats') / 'templates'
alc = on_alconna('更新模板', permission=SUPERUSER)
@driver.on_startup
async def init_templates() -> None:
@@ -58,3 +62,9 @@ async def init_templates() -> None:
logger.error(i)
raise RuntimeError('更新模板仓库失败')
logger.success('模板仓库更新成功')
@alc.handle()
async def _():
await init_templates()
await alc.finish('模板仓库更新成功')

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = 'nonebot-plugin-tetris-stats'
version = '1.1.0'
version = '1.1.3'
description = '一款基于 NoneBot2 的用于查询 Tetris 相关游戏数据的插件'
authors = ['scdhh <wallfjjd@gmail.com>']
readme = 'README.md'