diff --git a/plugins/web_ui/api/tabs/main/__init__.py b/plugins/web_ui/api/tabs/main/__init__.py index fdbe8888..ac892e65 100644 --- a/plugins/web_ui/api/tabs/main/__init__.py +++ b/plugins/web_ui/api/tabs/main/__init__.py @@ -1,6 +1,7 @@ import asyncio import time from datetime import datetime, timedelta +from pathlib import Path from typing import List, Optional import nonebot @@ -84,7 +85,13 @@ async def _(bot_id: Optional[str] = None) -> Result: if select_bot.connect_time: connect_date = datetime.fromtimestamp(select_bot.connect_time) select_bot.connect_date = connect_date.strftime("%Y-%m-%d %H:%M:%S") - + version_file = Path() / "__version__" + if version_file.exists(): + if text := version_file.open().read(): + if ver := text.replace("__version__: ", "").strip(): + select_bot.version = ver + day_call = await Statistics.filter(create_time__gte=now - timedelta(hours=now.hour)).count() + select_bot.day_call = day_call return Result.ok(bot_list, "拿到信息啦!") return Result.warning_("无Bot连接...") diff --git a/plugins/web_ui/api/tabs/main/model.py b/plugins/web_ui/api/tabs/main/model.py index bced1817..7dd770c6 100644 --- a/plugins/web_ui/api/tabs/main/model.py +++ b/plugins/web_ui/api/tabs/main/model.py @@ -35,14 +35,6 @@ class BaseInfo(BaseModel): """群聊数量""" received_messages: int = 0 """今日 累计接收消息""" - # received_messages_day: int = 0 - # """今日累计接收消息""" - # received_messages_week: int = 0 - # """一周内累计接收消息""" - # received_messages_month: int = 0 - # """一月内累计接收消息""" - # received_messages_year: int = 0 - # """一年内累计接受消息""" connect_time: int = 0 """连接时间""" connect_date: Optional[datetime] = None @@ -60,6 +52,11 @@ class BaseInfo(BaseModel): config: Optional[Config] = None """nb配置""" + day_call: int = 0 + """今日调用插件次数""" + version: str = "unknown" + """真寻版本""" + class Config: arbitrary_types_allowed = True