diff --git a/zhenxun/builtin_plugins/check/__init__.py b/zhenxun/builtin_plugins/check/__init__.py index d2f70b8f..0e73e8ad 100644 --- a/zhenxun/builtin_plugins/check/__init__.py +++ b/zhenxun/builtin_plugins/check/__init__.py @@ -23,6 +23,7 @@ __plugin_meta__ = PluginMetadata( 查看服务器当前状态 指令: 自检 + 戳一戳BOT """.strip(), extra=PluginExtraData( author="HibiKier", version="0.1", plugin_type=PluginType.SUPERUSER @@ -30,35 +31,7 @@ __plugin_meta__ = PluginMetadata( ) -_matcher = on_alconna( - Alconna("自检"), rule=to_me(), permission=SUPERUSER, block=True, priority=1 -) - -@_matcher.handle() -async def _(session: EventSession, arparma: Arparma): - try: - logger.info("触发自检") - data = await get_status_info() - image = await template_to_pic( - template_path=str((TEMPLATE_PATH / "check").absolute()), - template_name="main.html", - templates={"data": data}, - pages={ - "viewport": {"width": 195, "height": 750}, - "base_url": f"file://{TEMPLATE_PATH}", - }, - wait=2, - ) - await MessageUtils.build_message(image).send() - logger.info("自检成功", arparma.header_result, session=session) - except Exception as e: - await MessageUtils.build_message(f"自检失败: {e}").send() - logger.error("自检失败", arparma.header_result, session=session, e=e) - -_matcherI = on_notice(priority=1, block=True, rule=notice_rule(PokeNotifyEvent) & to_me()) - -@_matcherI.handle() -async def _(event: PokeNotifyEvent): +async def handle_self_check(): try: logger.info("触发自检") data = await get_status_info() @@ -78,4 +51,19 @@ async def _(event: PokeNotifyEvent): await MessageUtils.build_message(f"自检失败: {e}").send() logger.error("自检失败", e=e) +#word +_self_check_matcher = on_alconna( + Alconna("自检"), rule=to_me(), permission=SUPERUSER, block=True, priority=1 +) + +@_self_check_matcher.handle() +async def _(): + await handle_self_check() + +#poke +_self_check_poke_matcher = on_notice(priority=5, block=True, rule=notice_rule(PokeNotifyEvent) & to_me()) + +@_self_check_poke_matcher.handle() +async def _(event: PokeNotifyEvent): + await handle_self_check()