Files
HeXi/plugin_template/nonebot_plugin_template/handlers/entry.py
T
sansenhoshiandClaude b61d09f09f Add HeXi bot codebase: custom plugins, web frontends, tests
- hexi core: message handling, rate limiting, cooldown, plugin manager
- Custom plugins: BF stats, daily check-in, quotes, persona cards, etc.
- Community plugins vendored under hexi/plugins with local fixes
- Web admin frontends (learning-chat, persona-admin), unified hexi/web
- Tests for rate_limit/cooldown/memes/persona; poetry.lock

Co-Authored-By: Claude <noreply@anthropic.com>
2026-09-01 13:13:40 +08:00

30 lines
915 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_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()