infinity-qqbot 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- infinity_qqbot/__init__.py +78 -0
- infinity_qqbot/api.py +1625 -0
- infinity_qqbot/engine.py +98 -0
- infinity_qqbot/events.py +973 -0
- infinity_qqbot/gateway.py +337 -0
- infinity_qqbot/handlers.py +281 -0
- infinity_qqbot/models/__init__.py +146 -0
- infinity_qqbot/models/base.py +13 -0
- infinity_qqbot/models/common.py +94 -0
- infinity_qqbot/models/enums.py +97 -0
- infinity_qqbot/models/group.py +190 -0
- infinity_qqbot/models/interaction.py +49 -0
- infinity_qqbot/models/menu.py +105 -0
- infinity_qqbot/models/message.py +204 -0
- infinity_qqbot/models/payloads.py +253 -0
- infinity_qqbot/models/responses.py +309 -0
- infinity_qqbot/py.typed +0 -0
- infinity_qqbot/rpc/__init__.py +27 -0
- infinity_qqbot/rpc/channels.py +3887 -0
- infinity_qqbot/rpc/groups.py +1204 -0
- infinity_qqbot/rpc/handlers/__init__.py +40 -0
- infinity_qqbot/rpc/handlers/channels.py +1019 -0
- infinity_qqbot/rpc/handlers/groups.py +325 -0
- infinity_qqbot/rpc/handlers/interactions.py +224 -0
- infinity_qqbot/rpc/handlers/messages.py +268 -0
- infinity_qqbot/rpc/interactions.py +820 -0
- infinity_qqbot/rpc/messages.py +930 -0
- infinity_qqbot-0.1.0.dist-info/METADATA +300 -0
- infinity_qqbot-0.1.0.dist-info/RECORD +31 -0
- infinity_qqbot-0.1.0.dist-info/WHEEL +4 -0
- infinity_qqbot-0.1.0.dist-info/licenses/LICENSE.md +21 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""infinity_qqbot —— 基于 ``infinity_bus`` 的强类型 QQ 机器人引擎。
|
|
2
|
+
|
|
3
|
+
模块结构:
|
|
4
|
+
|
|
5
|
+
- :mod:`infinity_qqbot.models`:按域拆分的 Pydantic 数据模型
|
|
6
|
+
(基础对象 / 消息 / 互动 / 群聊 / 菜单 / 响应 / 事件负载);
|
|
7
|
+
- :mod:`infinity_qqbot.api`:``QQBotAPI`` —— aiohttp + certifi 的 OpenAPI 封装;
|
|
8
|
+
- :mod:`infinity_qqbot.gateway`:``QQBotGateway`` —— WebSocket 网关客户端;
|
|
9
|
+
- :mod:`infinity_qqbot.engine`:``QQBot`` —— API + 网关组成的引擎;
|
|
10
|
+
- :mod:`infinity_qqbot.events`:QQ 网关事件声明(嵌套 ``Payload`` 风格,定义即自动收集);
|
|
11
|
+
- :mod:`infinity_qqbot.rpc`:强类型 RPC —— 每方法请求 / 响应模型、事件声明、客户端
|
|
12
|
+
与 ``QQBotAPIHandler``(由 ``tools/gen_rpc.py`` 生成);
|
|
13
|
+
- :mod:`infinity_qqbot.handlers`:``QQBotEventHandler`` 入站发布、``register_handlers`` 批量接线与工具。
|
|
14
|
+
|
|
15
|
+
快速开始::
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
|
|
19
|
+
from infinity_bus import EventBus, EventHandlerRegistry, EventRegistry
|
|
20
|
+
|
|
21
|
+
from infinity_qqbot import (
|
|
22
|
+
QQBotAPI,
|
|
23
|
+
qqbot_events,
|
|
24
|
+
register_handlers,
|
|
25
|
+
send_c2c_message,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
async def main():
|
|
29
|
+
api = QQBotAPI('你的AppID', '你的AppSecret')
|
|
30
|
+
|
|
31
|
+
registry = EventRegistry()
|
|
32
|
+
qqbot_events.register_all_events(registry) # 注册全部事件声明(网关事件 + RPC 事件)
|
|
33
|
+
|
|
34
|
+
handlers = EventHandlerRegistry()
|
|
35
|
+
register_handlers(handlers, api) # 入站发布 + 强类型 RPC 处理器
|
|
36
|
+
|
|
37
|
+
async with EventBus(registry, handlers) as bus:
|
|
38
|
+
message = await send_c2c_message(
|
|
39
|
+
bus.proxy('app'),
|
|
40
|
+
user_openid='用户 openid',
|
|
41
|
+
content='hello',
|
|
42
|
+
)
|
|
43
|
+
print(message.id)
|
|
44
|
+
|
|
45
|
+
asyncio.run(main())
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
from . import api as api
|
|
49
|
+
from . import engine as engine
|
|
50
|
+
from . import events as events
|
|
51
|
+
from . import gateway as gateway
|
|
52
|
+
from . import handlers as handlers
|
|
53
|
+
from . import models as models
|
|
54
|
+
from . import rpc as rpc
|
|
55
|
+
from .api import QQBOT_API_BASE as QQBOT_API_BASE
|
|
56
|
+
from .api import QQBotAPI as QQBotAPI
|
|
57
|
+
from .api import QQBotAPIError as QQBotAPIError
|
|
58
|
+
from .engine import QQBot as QQBot
|
|
59
|
+
from .events import *
|
|
60
|
+
from .events import ALL_EVENTS as ALL_EVENTS
|
|
61
|
+
from .events import EVENT_BY_TYPE as EVENT_BY_TYPE
|
|
62
|
+
from .events import qqbot_events as qqbot_events
|
|
63
|
+
from .events import resolve_event as resolve_event
|
|
64
|
+
from .gateway import QQBotEvent as QQBotEvent
|
|
65
|
+
from .gateway import QQBotGateway as QQBotGateway
|
|
66
|
+
from .gateway import QQBotGatewayClosed as QQBotGatewayClosed
|
|
67
|
+
from .gateway import QQBotGatewayError as QQBotGatewayError
|
|
68
|
+
from .handlers import QQBotEventHandler as QQBotEventHandler
|
|
69
|
+
from .handlers import register_handlers as register_handlers
|
|
70
|
+
from .handlers import wait_for_event as wait_for_event
|
|
71
|
+
from .models import *
|
|
72
|
+
from .rpc import *
|
|
73
|
+
from .rpc import QQBotAPIHandler as QQBotAPIHandler
|
|
74
|
+
|
|
75
|
+
# rpc 的星导出会带入其子模块名(channels / groups / handlers / ...),
|
|
76
|
+
# 这里恢复本包 ``handlers`` 子模块别名,避免被 ``rpc.handlers`` 覆盖
|
|
77
|
+
|
|
78
|
+
__version__ = '0.1.0'
|