Files
HeXi/dev/plugin_template/nonebot_plugin_template/handlers/entry.py
T
sansenhoshi 131b92b319 结构调整
视频解析多图/多媒体结构 消息体适配
2026-09-08 14:25:32 +08:00

30 lines
923 B
Python

"""触发器(Trigger)层:接触发 → 鉴权 → 调 service → 出 View。"""
from __future__ import annotations
from nonebot import on_command
from nonebot.adapters import Message
from nonebot.rule import to_me
from nonebot.params import CommandArg
from nonebot_plugin_alconna import UniMessage
from hexi.web_hub.web_config import get_effective_value
from ..services.main import do_something
_PLUGIN_ID = __package__.rsplit(".", 1)[0]
cmd = on_command("模板指令", aliases={"模板"}, rule=to_me(), priority=10, block=True)
@cmd.handle()
async def handle(arg: Message = CommandArg()):
if not get_effective_value(_PLUGIN_ID, "enable", True):
await cmd.finish("模板插件已停用")
return
text = arg.extract_plain_text().strip()
if not text:
await cmd.finish("请提供要记录的内容")
result = await do_something(text)
await UniMessage.text(result).send()