mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
新增获取自检状态方法
This commit is contained in:
parent
86718dd38c
commit
ab24d035a4
@ -23,6 +23,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
查看服务器当前状态
|
查看服务器当前状态
|
||||||
指令:
|
指令:
|
||||||
自检
|
自检
|
||||||
|
戳一戳BOT
|
||||||
""".strip(),
|
""".strip(),
|
||||||
extra=PluginExtraData(
|
extra=PluginExtraData(
|
||||||
author="HibiKier", version="0.1", plugin_type=PluginType.SUPERUSER
|
author="HibiKier", version="0.1", plugin_type=PluginType.SUPERUSER
|
||||||
@ -30,35 +31,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
_matcher = on_alconna(
|
async def handle_self_check():
|
||||||
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):
|
|
||||||
try:
|
try:
|
||||||
logger.info("触发自检")
|
logger.info("触发自检")
|
||||||
data = await get_status_info()
|
data = await get_status_info()
|
||||||
@ -78,4 +51,19 @@ async def _(event: PokeNotifyEvent):
|
|||||||
await MessageUtils.build_message(f"自检失败: {e}").send()
|
await MessageUtils.build_message(f"自检失败: {e}").send()
|
||||||
logger.error("自检失败", e=e)
|
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()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user