- 旧平铺模块(data/data_utils/database_op/image_builder*/get_bf6_data/ gametools_bf6/bf6_data/img_utils)拆分为 handlers(绑定/查询)、 services(fetchers/processing/query)、utils(渲染/参数)分层; 新增 repository.py / config.py / paths.py - 字体/图片/模板资源迁入 res/,新增 BF2042 卡面素材(bg/object_icon 等) - browser_ext/:BF2042 扩展捕获桥(WS 直连兜底通道)源码入库 - 新增 hexi/web/src/plugins/bf_bot 前端管理页 - 新增 tests:test_bf_bot_helpers / repository / tracker_api Co-Authored-By: Claude Code <noreply@anthropic.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
"""绑定管理命令:/bfbind(绑定) /unbind(解绑) /update_bind(修改绑定)。"""
|
|
|
|
from nonebot import on_command
|
|
from nonebot.adapters import Event, Message
|
|
from nonebot.params import CommandArg
|
|
from nonebot.rule import to_me
|
|
from nonebot_plugin_alconna import UniMessage
|
|
|
|
from ..services import binding as binding_service
|
|
|
|
bind_cmd = on_command("bfbind", rule=to_me(), aliases={"绑定"}, block=True)
|
|
unbind_cmd = on_command("unbind", rule=to_me(), aliases={"解绑"}, block=True)
|
|
update_bind_cmd = on_command(
|
|
"update_bind", rule=to_me(), aliases={"修改绑定"}, block=True
|
|
)
|
|
|
|
|
|
async def _reply(event: Event, text: str) -> None:
|
|
await UniMessage.at(user_id=event.get_user_id()).text(text).send()
|
|
|
|
|
|
@bind_cmd.handle()
|
|
async def handle_bind(event: Event, msg: Message = CommandArg()):
|
|
text = await binding_service.bind(event.get_user_id(), msg.extract_plain_text())
|
|
await _reply(event, text)
|
|
|
|
|
|
@unbind_cmd.handle()
|
|
async def handle_unbind(event: Event):
|
|
text = await binding_service.unbind(event.get_user_id())
|
|
await _reply(event, text)
|
|
|
|
|
|
@update_bind_cmd.handle()
|
|
async def handle_update_bind(event: Event, msg: Message = CommandArg()):
|
|
text = await binding_service.update_bind(
|
|
event.get_user_id(), msg.extract_plain_text()
|
|
)
|
|
await _reply(event, text)
|