zhenxun_bot/plugins/check_zhenxun_update/__init__.py
2021-08-06 19:42:02 +08:00

30 lines
780 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from nonebot.adapters.cqhttp import Bot, MessageEvent
from nonebot.typing import T_State
from nonebot.permission import SUPERUSER
from nonebot import on_command
from .data_source import check_update
update_zhenxun = on_command('检查更新真寻', permission=SUPERUSER, priority=1, block=True)
@update_zhenxun.handle()
async def _(bot: Bot, event: MessageEvent, state: T_State):
try:
await check_update(bot)
except Exception as e:
await bot.send_private_msg(
user_id=int(list(bot.config.superusers)[0]),
message=f'更新真寻未知错误 {type(e)}{e}'
)
else:
await bot.send_private_msg(
user_id=int(list(bot.config.superusers)[0]),
message=f'请重启真寻....'
)