refactor!: Bot 门面接管启动,移除 main/run_loop 与控制台脚本入口

bot.run() 同步启动、bot.start() 嵌入外部 asyncio 应用;
bot.call_api 通用 REST、bot.api 类型化 API 面、bot.services 自定义组件注入;
services 登记扩到 8 项(含 Bot 自身,可标注注入)。
This commit is contained in:
snowy-yang committed 2026-10-03 19:12:06 +08:00
1 parent 1f91b1acca
commit 0515c6e4c0
10 files changed
+317 -697

No files matched your search

+4 -4
View File
@@ -11,14 +11,14 @@
运行:uv run python examples/webhook_bot/main.py
"""
from qqbotsdk import EventEmitter, main
from qqbotsdk import Bot
from qqbotsdk.api import BotApi
from qqbotsdk.payloads import GroupAtMessage
ee = EventEmitter()
bot = Bot()
@ee.on("GROUP_AT_MESSAGE_CREATE")
@bot.on("GROUP_AT_MESSAGE_CREATE")
async def on_group_message(msg: GroupAtMessage, api: BotApi) -> None:
if not (msg.group_openid and msg.id):
return
@@ -30,4 +30,4 @@ async def on_group_message(msg: GroupAtMessage, api: BotApi) -> None:
if __name__ == "__main__":
main(ee)
bot.run()