euler-onebot 0.0.2__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.
- euler_onebot-0.0.2.dist-info/METADATA +158 -0
- euler_onebot-0.0.2.dist-info/RECORD +19 -0
- euler_onebot-0.0.2.dist-info/WHEEL +5 -0
- euler_onebot-0.0.2.dist-info/licenses/LICENSE +674 -0
- euler_onebot-0.0.2.dist-info/top_level.txt +1 -0
- euleronebot/config.py +79 -0
- euleronebot/hyperogger.py +171 -0
- euleronebot/onebot/__init__.py +80 -0
- euleronebot/onebot/api.py +291 -0
- euleronebot/onebot/api_data.py +277 -0
- euleronebot/onebot/connector.py +117 -0
- euleronebot/onebot/events.py +215 -0
- euleronebot/onebot/models.py +11 -0
- euleronebot/onebot/segments.py +159 -0
- euleronebot/protocol.py +528 -0
- euleronebot/utils/__init__.py +28 -0
- euleronebot/utils/infomgr.py +105 -0
- euleronebot/utils/transformer.py +224 -0
- euleronebot/versions.py +2 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
from pydantic import BaseModel, RootModel
|
|
2
|
+
from typing import Any, TYPE_CHECKING, Literal, Union
|
|
3
|
+
|
|
4
|
+
from ..versions import NAME, VERSION
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from .segments import BaseSegment, Node, SegmentUnion
|
|
8
|
+
from .events import GroupSender, PrivateSender
|
|
9
|
+
|
|
10
|
+
SEGMENT = BaseSegment
|
|
11
|
+
NODE = Node
|
|
12
|
+
GROUP_SENDER = GroupSender
|
|
13
|
+
PRIVATE_SENDER = PrivateSender
|
|
14
|
+
else:
|
|
15
|
+
from .segments import SegmentUnion
|
|
16
|
+
SEGMENT = SegmentUnion
|
|
17
|
+
NODE = Any
|
|
18
|
+
GROUP_SENDER = Any
|
|
19
|
+
PRIVATE_SENDER = Any
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"SendPrivateMsgData",
|
|
24
|
+
"SendGroupMsgData",
|
|
25
|
+
"SendMsgData",
|
|
26
|
+
"SendMsgRsp",
|
|
27
|
+
"DeleteMsgData",
|
|
28
|
+
"EmptyRsp",
|
|
29
|
+
"GetMsgData",
|
|
30
|
+
"GetMsgRsp",
|
|
31
|
+
"GetForwardMsgData",
|
|
32
|
+
"GetForwardMsgRsp",
|
|
33
|
+
"SendLikeData",
|
|
34
|
+
"SetGroupKickData",
|
|
35
|
+
"SetGroupBanData",
|
|
36
|
+
"SetGroupWholeBanData",
|
|
37
|
+
"SetGroupAdminData",
|
|
38
|
+
"SetGroupCardData",
|
|
39
|
+
"SetGroupNameData",
|
|
40
|
+
"SetGroupLeaveData",
|
|
41
|
+
"SetGroupSpecialTitleData",
|
|
42
|
+
"SetFriendAddRequestData",
|
|
43
|
+
"SetGroupAddRequestData",
|
|
44
|
+
"GetLoginInfoData",
|
|
45
|
+
"GetLoginInfoRsp",
|
|
46
|
+
"GetStrangerInfoData",
|
|
47
|
+
"GetStrangerInfoRsp",
|
|
48
|
+
"GetFriendListData",
|
|
49
|
+
"FriendElem",
|
|
50
|
+
"GetFriendListRsp",
|
|
51
|
+
"GetGroupInfoData",
|
|
52
|
+
"GetGroupInfoRsp",
|
|
53
|
+
"GetGroupListData",
|
|
54
|
+
"GetGroupListRsp",
|
|
55
|
+
"GetGroupMemberInfoData",
|
|
56
|
+
"GetGroupMemberInfoRsp",
|
|
57
|
+
"GetGroupMemberListData",
|
|
58
|
+
"GetGroupMemberListRsp",
|
|
59
|
+
"GetStatusData",
|
|
60
|
+
"GetVersionInfoData",
|
|
61
|
+
"GetVersionInfoRsp",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class SendPrivateMsgData(BaseModel):
|
|
66
|
+
user_id: int
|
|
67
|
+
message: list[SEGMENT]
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class SendGroupMsgData(BaseModel):
|
|
71
|
+
group_id: int
|
|
72
|
+
message: list[SEGMENT]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class SendMsgData(BaseModel):
|
|
76
|
+
message_type: Literal["private", "group", ""] = ""
|
|
77
|
+
user_id: int = 0
|
|
78
|
+
group_id: int = 0
|
|
79
|
+
message: list[SEGMENT]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class SendMsgRsp(BaseModel):
|
|
83
|
+
message_id: int
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class DeleteMsgData(BaseModel):
|
|
87
|
+
message_id: int
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class EmptyRsp(BaseModel):
|
|
91
|
+
...
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class GetMsgData(BaseModel):
|
|
95
|
+
message_id: int
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class GetMsgRsp(BaseModel):
|
|
99
|
+
time: int
|
|
100
|
+
message_type: Literal["private", "group"]
|
|
101
|
+
message_id: int
|
|
102
|
+
real_id: int
|
|
103
|
+
sender: Union[PRIVATE_SENDER, GROUP_SENDER]
|
|
104
|
+
message: list[SEGMENT]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class GetForwardMsgData(BaseModel):
|
|
108
|
+
id: str
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class GetForwardMsgRsp(BaseModel):
|
|
112
|
+
message: list[NODE]
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class SendLikeData(BaseModel):
|
|
116
|
+
user_id: int
|
|
117
|
+
times: int = 1
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class SetGroupKickData(BaseModel):
|
|
121
|
+
user_id: int
|
|
122
|
+
group_id: int
|
|
123
|
+
reject_add_request: bool = False
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class SetGroupBanData(BaseModel):
|
|
127
|
+
user_id: int
|
|
128
|
+
group_id: int
|
|
129
|
+
duration: int = 30 * 60
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class SetGroupWholeBanData(BaseModel):
|
|
133
|
+
group_id: int
|
|
134
|
+
enable: bool = True
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class SetGroupAdminData(BaseModel):
|
|
138
|
+
user_id: int
|
|
139
|
+
group_id: int
|
|
140
|
+
enable: bool = True
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class SetGroupCardData(BaseModel):
|
|
144
|
+
user_id: int
|
|
145
|
+
group_id: int
|
|
146
|
+
card: str
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class SetGroupNameData(BaseModel):
|
|
150
|
+
group_id: int
|
|
151
|
+
group_name: str
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class SetGroupLeaveData(BaseModel):
|
|
155
|
+
group_id: int
|
|
156
|
+
is_dismiss: bool = False
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class SetGroupSpecialTitleData(BaseModel):
|
|
160
|
+
group_id: int
|
|
161
|
+
user_id: int
|
|
162
|
+
special_title: str
|
|
163
|
+
duration: int = -1
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class SetFriendAddRequestData(BaseModel):
|
|
167
|
+
flag: str
|
|
168
|
+
approve: bool = True
|
|
169
|
+
remark: str
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class SetGroupAddRequestData(BaseModel):
|
|
173
|
+
flag: str
|
|
174
|
+
sub_type: Literal["add", "invite"]
|
|
175
|
+
approve: bool = True
|
|
176
|
+
reason: str
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
class GetLoginInfoData(BaseModel):
|
|
180
|
+
...
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
class GetLoginInfoRsp(BaseModel):
|
|
184
|
+
user_id: int
|
|
185
|
+
nickname: str
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class GetStrangerInfoData(BaseModel):
|
|
189
|
+
user_id: int
|
|
190
|
+
no_cache: bool = False
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class GetStrangerInfoRsp(BaseModel):
|
|
194
|
+
user_id: int
|
|
195
|
+
nickname: str
|
|
196
|
+
sex: Literal["male", "female", "unknown"]
|
|
197
|
+
age: int
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class GetFriendListData(BaseModel):
|
|
201
|
+
...
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class FriendElem(BaseModel):
|
|
205
|
+
user_id: int
|
|
206
|
+
nickname: str
|
|
207
|
+
remark: str
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class GetFriendListRsp(RootModel[list[FriendElem]]):
|
|
211
|
+
...
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class GetGroupInfoData(BaseModel):
|
|
215
|
+
group_id: int
|
|
216
|
+
no_cache: bool = False
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class GetGroupInfoRsp(BaseModel):
|
|
220
|
+
group_id: int
|
|
221
|
+
group_name: str
|
|
222
|
+
member_count: int
|
|
223
|
+
max_member_count: int
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
class GetGroupListData(BaseModel):
|
|
227
|
+
...
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class GetGroupListRsp(RootModel[list[GetGroupInfoRsp]]):
|
|
231
|
+
...
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class GetGroupMemberInfoData(BaseModel):
|
|
235
|
+
group_id: int
|
|
236
|
+
user_id: int
|
|
237
|
+
no_cache: bool = False
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
class GetGroupMemberInfoRsp(BaseModel):
|
|
241
|
+
group_id: int
|
|
242
|
+
user_id: int
|
|
243
|
+
nickname: str
|
|
244
|
+
card: str
|
|
245
|
+
sex: Literal["male", "female", "unknown"]
|
|
246
|
+
age: int
|
|
247
|
+
area: str
|
|
248
|
+
join_time: int
|
|
249
|
+
last_sent_time: int
|
|
250
|
+
level: str
|
|
251
|
+
role: str
|
|
252
|
+
unfriendly: bool = False
|
|
253
|
+
title: str
|
|
254
|
+
title_expire_time: int = -1
|
|
255
|
+
card_changeable: bool = True
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
class GetGroupMemberListData(BaseModel):
|
|
259
|
+
group_id: int
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
class GetGroupMemberListRsp(RootModel[list[GetGroupMemberInfoRsp]]):
|
|
263
|
+
...
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
class GetStatusData(BaseModel):
|
|
267
|
+
...
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
class GetVersionInfoData(BaseModel):
|
|
271
|
+
...
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
class GetVersionInfoRsp(BaseModel):
|
|
275
|
+
app_name: str = NAME
|
|
276
|
+
app_version: str = VERSION
|
|
277
|
+
protocol_version: str = "v11"
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
|
|
2
|
+
from typing import Literal, Self
|
|
3
|
+
from uvicorn import Config as UvicornConfig
|
|
4
|
+
from uvicorn import Server as UvicornServer
|
|
5
|
+
from urllib.parse import urlparse
|
|
6
|
+
import asyncio
|
|
7
|
+
|
|
8
|
+
from ..hyperogger import Logger
|
|
9
|
+
from ..config import AdapterConfig, ForwardWebsocketConfig
|
|
10
|
+
|
|
11
|
+
logger = Logger.fetch("euler").name_custom("euler.onebot.connector")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Connector:
|
|
15
|
+
def __init__(self, impls: list[AdapterConfig]):
|
|
16
|
+
self.impls = impls
|
|
17
|
+
self.forward_app: FastAPI = None
|
|
18
|
+
self.received: asyncio.Queue[str] = asyncio.Queue()
|
|
19
|
+
self.active_websocket_servers: dict[Literal["root", "api", "event"], WebSocket] = dict()
|
|
20
|
+
|
|
21
|
+
async def setup(self) -> Self:
|
|
22
|
+
for i in self.impls:
|
|
23
|
+
match i.type:
|
|
24
|
+
case "HTTP":
|
|
25
|
+
await self.set_http()
|
|
26
|
+
case "HTTPPost":
|
|
27
|
+
await self.set_http_post()
|
|
28
|
+
case "ForwardWebSocket":
|
|
29
|
+
await self.set_forward_websocket()
|
|
30
|
+
case "ReverseWebSocket":
|
|
31
|
+
await self.set_reverse_websocket()
|
|
32
|
+
case _:
|
|
33
|
+
raise RuntimeError(f"Unknown implementation: {i}")
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
async def __aenter__(self) -> Self:
|
|
37
|
+
return await self.setup()
|
|
38
|
+
|
|
39
|
+
async def __aexit__(self) -> None:
|
|
40
|
+
del self
|
|
41
|
+
|
|
42
|
+
async def set_http(self) -> None:
|
|
43
|
+
raise NotImplementedError
|
|
44
|
+
|
|
45
|
+
async def set_http_post(self) -> None:
|
|
46
|
+
raise NotImplementedError
|
|
47
|
+
|
|
48
|
+
async def set_forward_websocket(self) -> None:
|
|
49
|
+
self.forward_app = FastAPI()
|
|
50
|
+
|
|
51
|
+
@self.forward_app.websocket("/")
|
|
52
|
+
async def websocket_endpoint(websocket: WebSocket):
|
|
53
|
+
await websocket.accept()
|
|
54
|
+
self.active_websocket_servers["root"] = websocket
|
|
55
|
+
try:
|
|
56
|
+
while True:
|
|
57
|
+
await self.received.put(await websocket.receive_text())
|
|
58
|
+
except WebSocketDisconnect:
|
|
59
|
+
logger.error("连接断开")
|
|
60
|
+
|
|
61
|
+
@self.forward_app.websocket("/api")
|
|
62
|
+
async def api_endpoint(websocket: WebSocket):
|
|
63
|
+
await websocket.accept()
|
|
64
|
+
self.active_websocket_servers["api"] = websocket
|
|
65
|
+
try:
|
|
66
|
+
while True:
|
|
67
|
+
await self.received.put(await websocket.receive_text())
|
|
68
|
+
except WebSocketDisconnect:
|
|
69
|
+
logger.error("连接断开")
|
|
70
|
+
|
|
71
|
+
@self.forward_app.websocket("/event")
|
|
72
|
+
async def event_endpoint(websocket: WebSocket):
|
|
73
|
+
await websocket.accept()
|
|
74
|
+
self.active_websocket_servers["event"] = websocket
|
|
75
|
+
while True:
|
|
76
|
+
await asyncio.sleep(1)
|
|
77
|
+
|
|
78
|
+
async def set_reverse_websocket(self) -> None:
|
|
79
|
+
raise NotImplementedError
|
|
80
|
+
|
|
81
|
+
async def run(self):
|
|
82
|
+
if self.forward_app:
|
|
83
|
+
cfg = None
|
|
84
|
+
for i in self.impls:
|
|
85
|
+
if isinstance(i, ForwardWebsocketConfig):
|
|
86
|
+
url = urlparse(i.url)
|
|
87
|
+
host = url.hostname
|
|
88
|
+
port = url.port
|
|
89
|
+
assert host is not None and port is not None
|
|
90
|
+
cfg = UvicornConfig(
|
|
91
|
+
self.forward_app,
|
|
92
|
+
host=host,
|
|
93
|
+
port=port,
|
|
94
|
+
log_config=None
|
|
95
|
+
)
|
|
96
|
+
break
|
|
97
|
+
assert cfg
|
|
98
|
+
server = UvicornServer(cfg)
|
|
99
|
+
await server.serve()
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
async def report(self, data: str) -> None:
|
|
104
|
+
logger.trace(f"API report: {data}")
|
|
105
|
+
if self.active_websocket_servers:
|
|
106
|
+
if self.active_websocket_servers.get("root"):
|
|
107
|
+
await self.active_websocket_servers["root"].send_text(data)
|
|
108
|
+
if self.active_websocket_servers.get("api"):
|
|
109
|
+
await self.active_websocket_servers["api"].send_text(data)
|
|
110
|
+
|
|
111
|
+
async def trigger(self, data: str) -> None:
|
|
112
|
+
logger.trace(f"Event trigger: {data}")
|
|
113
|
+
if self.active_websocket_servers:
|
|
114
|
+
if self.active_websocket_servers.get("root"):
|
|
115
|
+
await self.active_websocket_servers["root"].send_text(data)
|
|
116
|
+
if self.active_websocket_servers.get("event"):
|
|
117
|
+
await self.active_websocket_servers["event"].send_text(data)
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Literal, TYPE_CHECKING, Any, Union
|
|
3
|
+
|
|
4
|
+
from .models import BotStatus
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from .segments import BaseSegment
|
|
8
|
+
|
|
9
|
+
SEGMENT = BaseSegment
|
|
10
|
+
else:
|
|
11
|
+
SEGMENT = Any
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"BaseEvent",
|
|
15
|
+
"PrivateSender",
|
|
16
|
+
"GroupSender",
|
|
17
|
+
"MessageEvent",
|
|
18
|
+
"GroupMessageEvent",
|
|
19
|
+
"PrivateMessageEvent",
|
|
20
|
+
"NoticeEvent",
|
|
21
|
+
"FileInfo",
|
|
22
|
+
"GroupFileUploadEvent",
|
|
23
|
+
"GroupAdminEvent",
|
|
24
|
+
"GroupDecreaseEvent",
|
|
25
|
+
"GroupIncreaseEvent",
|
|
26
|
+
"GroupMuteEvent",
|
|
27
|
+
"FriendAddEvent",
|
|
28
|
+
"GroupRecallEvent",
|
|
29
|
+
"FriendRecallEvent",
|
|
30
|
+
"GroupPokeEvent",
|
|
31
|
+
"RequestEvent",
|
|
32
|
+
"FriendRequestEvent",
|
|
33
|
+
"GroupRequestEvent",
|
|
34
|
+
"MetaEvent",
|
|
35
|
+
"LifecycleEvent",
|
|
36
|
+
"HeartbeatEvent",
|
|
37
|
+
"ReactionEvent"
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class BaseEvent(BaseModel):
|
|
42
|
+
time: int
|
|
43
|
+
self_id: int
|
|
44
|
+
post_type: Literal["message", "notice", "request", "meta_event"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class PrivateSender(BaseModel):
|
|
48
|
+
user_id: int
|
|
49
|
+
nickname: str
|
|
50
|
+
sex: Literal["male", "female", "unknown"]
|
|
51
|
+
age: int
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class GroupSender(BaseModel):
|
|
55
|
+
user_id: int
|
|
56
|
+
nickname: str
|
|
57
|
+
sex: Literal["male", "female", "unknown"]
|
|
58
|
+
age: int
|
|
59
|
+
card: str
|
|
60
|
+
area: str
|
|
61
|
+
level: str
|
|
62
|
+
role: Literal["owner", "admin", "member"]
|
|
63
|
+
title: str
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class MessageEvent(BaseEvent):
|
|
67
|
+
post_type: Literal["message"] = "message"
|
|
68
|
+
message_type: Literal["private", "group"]
|
|
69
|
+
sub_type: Literal["friend", "group", "other"]
|
|
70
|
+
message_id: int
|
|
71
|
+
user_id: int
|
|
72
|
+
message: list[SEGMENT]
|
|
73
|
+
raw_message: str
|
|
74
|
+
font: int = 0
|
|
75
|
+
sender: Union[PrivateSender, GroupSender]
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class GroupMessageEvent(MessageEvent):
|
|
79
|
+
message_type: Literal["group"] = "group"
|
|
80
|
+
sub_type: Literal["group"] = "group"
|
|
81
|
+
anonymous: None = None
|
|
82
|
+
sender: Union[GroupSender]
|
|
83
|
+
group_id: int
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class PrivateMessageEvent(MessageEvent):
|
|
87
|
+
message_type: Literal["private"] = "private"
|
|
88
|
+
sub_type: Literal["friend"] = "friend"
|
|
89
|
+
sender: Union[PrivateSender]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class NoticeEvent(BaseEvent):
|
|
93
|
+
post_type: Literal["notice"] = "notice"
|
|
94
|
+
notice_type: Literal[
|
|
95
|
+
"group_upload", "group_admin", "group_decrease", "group_increase", "group_ban", "friend_add", "group_recall", "friend_recall", "notify", "reaction"]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class FileInfo(BaseModel):
|
|
99
|
+
id: str
|
|
100
|
+
name: str
|
|
101
|
+
size: int
|
|
102
|
+
busid: int
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class GroupFileUploadEvent(NoticeEvent):
|
|
106
|
+
notice_type: Literal["group_upload"] = "group_upload"
|
|
107
|
+
group_id: int
|
|
108
|
+
user_id: int
|
|
109
|
+
file: FileInfo
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class GroupAdminEvent(NoticeEvent):
|
|
113
|
+
notice_type: Literal["group_admin"] = "group_admin"
|
|
114
|
+
sub_type: Literal["set", "unset"]
|
|
115
|
+
group_id: int
|
|
116
|
+
user_id: int
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class GroupDecreaseEvent(NoticeEvent):
|
|
120
|
+
notice_type: Literal["group_decrease"] = "group_decrease"
|
|
121
|
+
sub_type: Literal["leave", "kick", "kick_me"]
|
|
122
|
+
group_id: int
|
|
123
|
+
operator_id: int
|
|
124
|
+
user_id: int
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class GroupIncreaseEvent(NoticeEvent):
|
|
128
|
+
notice_type: Literal["group_increase"] = "group_increase"
|
|
129
|
+
sub_type: Literal["approve", "invite"]
|
|
130
|
+
group_id: int
|
|
131
|
+
operator_id: int
|
|
132
|
+
user_id: int
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class GroupMuteEvent(NoticeEvent):
|
|
136
|
+
notice_type: Literal["group_ban"] = "group_ban"
|
|
137
|
+
sub_type: Literal["ban", "lift_ban"]
|
|
138
|
+
group_id: int
|
|
139
|
+
operator_id: int
|
|
140
|
+
user_id: int
|
|
141
|
+
duration: int
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class FriendAddEvent(NoticeEvent):
|
|
145
|
+
notice_type: Literal["friend_add"] = "friend_add"
|
|
146
|
+
user_id: int
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class GroupRecallEvent(NoticeEvent):
|
|
150
|
+
notice_type: Literal["group_recall"] = "group_recall"
|
|
151
|
+
group_id: int
|
|
152
|
+
operator_id: int
|
|
153
|
+
user_id: int
|
|
154
|
+
message_id: int
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class FriendRecallEvent(NoticeEvent):
|
|
158
|
+
notice_type: Literal["friend_recall"] = "friend_recall"
|
|
159
|
+
user_id: int
|
|
160
|
+
message_id: int
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class GroupPokeEvent(NoticeEvent):
|
|
164
|
+
notice_type: Literal["notify"] = "notify"
|
|
165
|
+
sub_type: Literal["poke"] = "poke"
|
|
166
|
+
group_id: int
|
|
167
|
+
group_id: int
|
|
168
|
+
target_id: int
|
|
169
|
+
user_id: int
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class ReactionEvent(NoticeEvent):
|
|
173
|
+
notice_type: Literal["reaction"] = "reaction"
|
|
174
|
+
message_id: int
|
|
175
|
+
operator_id: int
|
|
176
|
+
sub_type: Literal["add", "remove"]
|
|
177
|
+
code: int
|
|
178
|
+
count: int
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class RequestEvent(BaseEvent):
|
|
182
|
+
post_type: Literal["request"] = "request"
|
|
183
|
+
request_type: Literal["friend", "group"]
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class FriendRequestEvent(RequestEvent):
|
|
187
|
+
request_type: Literal["friend"] = "friend"
|
|
188
|
+
user_id: int
|
|
189
|
+
comment: str
|
|
190
|
+
flag: str
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class GroupRequestEvent(RequestEvent):
|
|
194
|
+
request_type: Literal["group"] = "group"
|
|
195
|
+
sub_type: Literal["add", "invite"]
|
|
196
|
+
group_id: int
|
|
197
|
+
user_id: int
|
|
198
|
+
comment: str
|
|
199
|
+
flag: str
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class MetaEvent(BaseEvent):
|
|
203
|
+
post_type: Literal["meta_event"] = "meta_event"
|
|
204
|
+
meta_event_type: Literal["lifecycle", "heartbeat"]
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class LifecycleEvent(MetaEvent):
|
|
208
|
+
meta_event_type: Literal["lifecycle"] = "lifecycle"
|
|
209
|
+
sub_type: Literal["enable", "disable", "connect"]
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class HeartbeatEvent(MetaEvent):
|
|
213
|
+
meta_event_type: Literal["heartbeat"] = "heartbeat"
|
|
214
|
+
status: BotStatus
|
|
215
|
+
interval: int
|