mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-14 21:52:56 +08:00
✨ 添加获取nb配置api
This commit is contained in:
parent
fe1634eb2d
commit
792bcaa711
@ -1,7 +1,9 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import nonebot
|
||||
from nonebot import require
|
||||
from fastapi import APIRouter
|
||||
from nonebot.config import Config
|
||||
from tortoise.functions import Count
|
||||
from tortoise.expressions import RawSQL
|
||||
from fastapi.responses import JSONResponse
|
||||
@ -19,6 +21,8 @@ require("plugin_store")
|
||||
|
||||
router = APIRouter(prefix="/dashboard")
|
||||
|
||||
driver = nonebot.get_driver()
|
||||
|
||||
|
||||
@router.get(
|
||||
"/get_bot_list",
|
||||
@ -184,3 +188,14 @@ async def _(query: QueryModel) -> Result[BaseResultModel]:
|
||||
for v in data:
|
||||
v.connect_time = v.connect_time.replace(tzinfo=None).replace(microsecond=0)
|
||||
return Result.ok(BaseResultModel(total=total, data=data))
|
||||
|
||||
|
||||
@router.get(
|
||||
"/get_nonebot_config",
|
||||
dependencies=[authentication()],
|
||||
response_model=Result[Config],
|
||||
response_class=JSONResponse,
|
||||
deprecated="获取nb配置", # type: ignore
|
||||
)
|
||||
async def _() -> Result[Config]:
|
||||
return Result.ok(driver.config)
|
||||
|
||||
@ -108,7 +108,6 @@ async def _(bot_id: str | None = None) -> Result[list[BaseInfo]]:
|
||||
day_call = await Statistics.filter(
|
||||
create_time__gte=now - timedelta(hours=now.hour)
|
||||
).count()
|
||||
select_bot.config = driver.config
|
||||
select_bot.day_call = day_call
|
||||
select_bot.connect_count = await BotConnectLog.filter(
|
||||
bot_id=select_bot.self_id
|
||||
|
||||
@ -46,8 +46,6 @@ class BaseInfo(BaseModel):
|
||||
|
||||
is_select: bool = False
|
||||
"""当前选择"""
|
||||
config: Config | None
|
||||
"""nb配置"""
|
||||
day_call: int = 0
|
||||
"""今日调用插件次数"""
|
||||
version: str = "unknown"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user