mirror of
https://github.com/snowy-yang/qqbotsdk.git
synced 2026-10-21 12:24:49 +00:00
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:
1 parent
1f91b1acca
commit
0515c6e4c0
10 files changed
+317
-697
No files matched your search
@@ -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()
|
||||
Reference in new issue
Block a user