butterbot-python 3.1.0.dev1__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.
- butterbot/__init__.py +15 -0
- butterbot/app/__init__.py +41 -0
- butterbot/app/bot_app.py +374 -0
- butterbot/app/config.py +156 -0
- butterbot/app/source_manager.py +367 -0
- butterbot/core/__init__.py +46 -0
- butterbot/core/api/__init__.py +9 -0
- butterbot/core/api/base_api.py +32 -0
- butterbot/core/context/README.md +1 -0
- butterbot/core/context/__init__.py +9 -0
- butterbot/core/context/api_registry.py +109 -0
- butterbot/core/context/app_context.py +51 -0
- butterbot/core/context/config_provider.py +14 -0
- butterbot/core/data/__init__.py +15 -0
- butterbot/core/data/base_data.py +29 -0
- butterbot/core/data/base_model.py +197 -0
- butterbot/core/event/README.md +1 -0
- butterbot/core/event/__init__.py +10 -0
- butterbot/core/event/event.py +27 -0
- butterbot/core/event/event_bus.py +276 -0
- butterbot/core/event/subscriber.py +130 -0
- butterbot/core/exceptions.py +90 -0
- butterbot/core/filter/__init__.py +11 -0
- butterbot/core/filter/base_filter.py +74 -0
- butterbot/core/source/README.md +1 -0
- butterbot/core/source/__init__.py +9 -0
- butterbot/core/source/base_source.py +134 -0
- butterbot/core/types/__init__.py +9 -0
- butterbot/core/types/base_type.py +74 -0
- butterbot/sources/__init__.py +1 -0
- butterbot/sources/bilibili/README.md +10 -0
- butterbot/sources/bilibili/__init__.py +20 -0
- butterbot/sources/bilibili/api/__init__.py +5 -0
- butterbot/sources/bilibili/api/bili_api.py +123 -0
- butterbot/sources/bilibili/data/__init__.py +52 -0
- butterbot/sources/bilibili/data/danmaku_gift_data.py +135 -0
- butterbot/sources/bilibili/data/danmaku_guard_data.py +54 -0
- butterbot/sources/bilibili/data/danmaku_msg_data.py +71 -0
- butterbot/sources/bilibili/data/dto/__init__.py +59 -0
- butterbot/sources/bilibili/data/dto/danmaku_gift_dto.py +193 -0
- butterbot/sources/bilibili/data/dto/danmaku_guard_buy_dto.py +54 -0
- butterbot/sources/bilibili/data/dto/danmaku_msg_dto.py +123 -0
- butterbot/sources/bilibili/data/dto/dynamic_dto.py +276 -0
- butterbot/sources/bilibili/data/dto/live_room_dto.py +169 -0
- butterbot/sources/bilibili/data/dto/video_part_dto.py +18 -0
- butterbot/sources/bilibili/data/dynamic_data.py +362 -0
- butterbot/sources/bilibili/data/live_room_data.py +162 -0
- butterbot/sources/bilibili/data/video_part.py +46 -0
- butterbot/sources/bilibili/source/__init__.py +15 -0
- butterbot/sources/bilibili/source/base_polling_source.py +130 -0
- butterbot/sources/bilibili/source/bili_danmaku_source.py +230 -0
- butterbot/sources/bilibili/source/bili_dynamic_source.py +135 -0
- butterbot/sources/bilibili/source/bili_live_source.py +137 -0
- butterbot/sources/bilibili/types/__init__.py +11 -0
- butterbot/sources/bilibili/types/bili_type.py +32 -0
- butterbot/sources/napcat/README.md +10 -0
- butterbot/sources/napcat/__init__.py +20 -0
- butterbot/sources/napcat/api/__init__.py +3 -0
- butterbot/sources/napcat/api/napcat_api.py +316 -0
- butterbot/sources/napcat/data/__init__.py +179 -0
- butterbot/sources/napcat/data/event_data.py +441 -0
- butterbot/sources/napcat/data/segment_data.py +432 -0
- butterbot/sources/napcat/events.py +91 -0
- butterbot/sources/napcat/filters/__init__.py +19 -0
- butterbot/sources/napcat/filters/filters.py +202 -0
- butterbot/sources/napcat/source/__init__.py +5 -0
- butterbot/sources/napcat/source/napcat_source.py +58 -0
- butterbot/sources/napcat/types/__init__.py +5 -0
- butterbot/sources/napcat/types/napcat_type.py +61 -0
- butterbot/utils/README.md +15 -0
- butterbot/utils/__init__.py +11 -0
- butterbot/utils/data_pair.py +27 -0
- butterbot/utils/logging_config.py +521 -0
- butterbot/utils/terminal.py +308 -0
- butterbot/utils/websocket.py +1270 -0
- butterbot_python-3.1.0.dev1.dist-info/METADATA +769 -0
- butterbot_python-3.1.0.dev1.dist-info/RECORD +79 -0
- butterbot_python-3.1.0.dev1.dist-info/WHEEL +4 -0
- butterbot_python-3.1.0.dev1.dist-info/licenses/LICENSE +674 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NapCat OneBot11 事件数据模型
|
|
3
|
+
|
|
4
|
+
基于 OneBot11 协议定义的事件类型,使用 BaseDataModel 实现自动分发构造
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import ClassVar
|
|
8
|
+
|
|
9
|
+
from butterbot.core.data import BaseDataModel
|
|
10
|
+
|
|
11
|
+
from ..types import NapcatType
|
|
12
|
+
from .segment_data import NapcatMessage
|
|
13
|
+
|
|
14
|
+
# ==================== 嵌套数据类(发送者信息) ====================
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FriendSender(BaseDataModel):
|
|
18
|
+
"""私聊消息发送者信息"""
|
|
19
|
+
|
|
20
|
+
user_id: int
|
|
21
|
+
nickname: str
|
|
22
|
+
sex: str | None = None
|
|
23
|
+
age: int | None = None
|
|
24
|
+
group_id: int | None = None # 群临时会话会有此字段
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class GroupSender(BaseDataModel):
|
|
28
|
+
"""群消息发送者信息"""
|
|
29
|
+
|
|
30
|
+
user_id: int
|
|
31
|
+
nickname: str
|
|
32
|
+
sex: str | None = None
|
|
33
|
+
age: int | None = None
|
|
34
|
+
card: str | None = None # 群名片/备注
|
|
35
|
+
area: str | None = None # 地区
|
|
36
|
+
level: int | None = None # 成员等级
|
|
37
|
+
role: str | None = None # 角色: owner/admin/member
|
|
38
|
+
title: str | None = None # 专属头衔
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class FileInfo(BaseDataModel):
|
|
42
|
+
"""文件信息"""
|
|
43
|
+
|
|
44
|
+
id: str
|
|
45
|
+
name: str
|
|
46
|
+
size: int
|
|
47
|
+
busid: int
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class EmojiLike(BaseDataModel):
|
|
51
|
+
"""表情回应信息"""
|
|
52
|
+
|
|
53
|
+
count: int
|
|
54
|
+
emoji_id: int
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class HeartbeatStatus(BaseDataModel):
|
|
58
|
+
"""心跳状态信息"""
|
|
59
|
+
|
|
60
|
+
online: bool | None = None
|
|
61
|
+
good: bool | None = None
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ==================== 事件基类 ====================
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class NapcatData(BaseDataModel):
|
|
68
|
+
"""OneBot11 事件基类
|
|
69
|
+
|
|
70
|
+
使用 post_type 字段进行一级分发
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
discriminator_field: ClassVar[str] = "post_type"
|
|
74
|
+
event_type: ClassVar[NapcatType] = NapcatType.UNKNOWN
|
|
75
|
+
time: int
|
|
76
|
+
self_id: int
|
|
77
|
+
post_type: str
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
# ==================== 消息事件 ====================
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class NapcatMessageData(NapcatData):
|
|
84
|
+
"""消息事件基类
|
|
85
|
+
|
|
86
|
+
使用 message_type 字段进行二级分发
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
discriminator_value: ClassVar[str] = "message"
|
|
90
|
+
discriminator_field: ClassVar[str] = "message_type"
|
|
91
|
+
event_type: ClassVar[NapcatType] = NapcatType.MESSAGE
|
|
92
|
+
post_type: str = "message"
|
|
93
|
+
message_type: str
|
|
94
|
+
sub_type: str
|
|
95
|
+
message_id: int
|
|
96
|
+
user_id: int
|
|
97
|
+
message: NapcatMessage
|
|
98
|
+
raw_message: str
|
|
99
|
+
font: int
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class NapcatPrivateMessageData(NapcatMessageData):
|
|
103
|
+
"""私聊消息事件"""
|
|
104
|
+
|
|
105
|
+
discriminator_value: ClassVar[str] = "private"
|
|
106
|
+
event_type: ClassVar[NapcatType] = NapcatType.PRIVATE_MESSAGE
|
|
107
|
+
message_type: str = "private"
|
|
108
|
+
sub_type: str = "friend"
|
|
109
|
+
target_id: int | None = None # 接收者QQ
|
|
110
|
+
temp_source: int | None = None # 临时会话来源
|
|
111
|
+
sender: FriendSender
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class NapcatGroupMessageData(NapcatMessageData):
|
|
115
|
+
"""群消息事件"""
|
|
116
|
+
|
|
117
|
+
discriminator_value: ClassVar[str] = "group"
|
|
118
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_MESSAGE
|
|
119
|
+
message_type: str = "group"
|
|
120
|
+
sub_type: str = "normal" # normal/anonymous/notice
|
|
121
|
+
group_id: int
|
|
122
|
+
sender: GroupSender
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
# ==================== 消息发送事件(自身消息上报) ====================
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class NapcatMessageSentData(NapcatData):
|
|
129
|
+
"""消息发送事件基类(自身发送的消息上报)
|
|
130
|
+
|
|
131
|
+
使用 message_type 字段进行二级分发
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
discriminator_value: ClassVar[str] = "message_sent"
|
|
135
|
+
discriminator_field: ClassVar[str] = "message_type"
|
|
136
|
+
event_type: ClassVar[NapcatType] = NapcatType.SENT
|
|
137
|
+
post_type: str = "message_sent"
|
|
138
|
+
message_type: str
|
|
139
|
+
sub_type: str
|
|
140
|
+
message_id: int
|
|
141
|
+
user_id: int
|
|
142
|
+
message: NapcatMessage
|
|
143
|
+
raw_message: str
|
|
144
|
+
font: int
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
class NapcatPrivateMessageSentData(NapcatMessageSentData):
|
|
148
|
+
"""私聊消息发送事件"""
|
|
149
|
+
|
|
150
|
+
discriminator_value: ClassVar[str] = "private"
|
|
151
|
+
event_type: ClassVar[NapcatType] = NapcatType.PRIVATE_SENT
|
|
152
|
+
message_type: str = "private"
|
|
153
|
+
sub_type: str = "friend"
|
|
154
|
+
target_id: int | None = None
|
|
155
|
+
sender: FriendSender
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class NapcatGroupMessageSentData(NapcatMessageSentData):
|
|
159
|
+
"""群消息发送事件"""
|
|
160
|
+
|
|
161
|
+
discriminator_value: ClassVar[str] = "group"
|
|
162
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_SENT
|
|
163
|
+
message_type: str = "group"
|
|
164
|
+
sub_type: str = "normal"
|
|
165
|
+
group_id: int
|
|
166
|
+
sender: GroupSender
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# ==================== 通知事件 ====================
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
class NapcatNoticeData(NapcatData):
|
|
173
|
+
"""通知事件基类
|
|
174
|
+
|
|
175
|
+
使用 notice_type 字段进行二级分发
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
discriminator_value: ClassVar[str] = "notice"
|
|
179
|
+
discriminator_field: ClassVar[str] = "notice_type"
|
|
180
|
+
event_type: ClassVar[NapcatType] = NapcatType.NOTICE
|
|
181
|
+
post_type: str = "notice"
|
|
182
|
+
notice_type: str
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class NapcatGroupUploadNoticeData(NapcatNoticeData):
|
|
186
|
+
"""群文件上传事件"""
|
|
187
|
+
|
|
188
|
+
discriminator_value: ClassVar[str] = "group_upload"
|
|
189
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_UPLOAD_NOTICE
|
|
190
|
+
notice_type: str = "group_upload"
|
|
191
|
+
group_id: int
|
|
192
|
+
user_id: int
|
|
193
|
+
file: FileInfo
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class NapcatGroupAdminNoticeData(NapcatNoticeData):
|
|
197
|
+
"""群管理员变动事件"""
|
|
198
|
+
|
|
199
|
+
discriminator_value: ClassVar[str] = "group_admin"
|
|
200
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_ADMIN_NOTICE
|
|
201
|
+
notice_type: str = "group_admin"
|
|
202
|
+
sub_type: str # set/unset
|
|
203
|
+
group_id: int
|
|
204
|
+
user_id: int
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
class NapcatGroupDecreaseNoticeData(NapcatNoticeData):
|
|
208
|
+
"""群成员减少事件"""
|
|
209
|
+
|
|
210
|
+
discriminator_value: ClassVar[str] = "group_decrease"
|
|
211
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_DECREASE_NOTICE
|
|
212
|
+
notice_type: str = "group_decrease"
|
|
213
|
+
sub_type: str # leave/kick/kick_me
|
|
214
|
+
group_id: int
|
|
215
|
+
operator_id: int
|
|
216
|
+
user_id: int
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
class NapcatGroupIncreaseNoticeData(NapcatNoticeData):
|
|
220
|
+
"""群成员增加事件"""
|
|
221
|
+
|
|
222
|
+
discriminator_value: ClassVar[str] = "group_increase"
|
|
223
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_INCREASE_NOTICE
|
|
224
|
+
notice_type: str = "group_increase"
|
|
225
|
+
sub_type: str # approve/invite
|
|
226
|
+
group_id: int
|
|
227
|
+
operator_id: int
|
|
228
|
+
user_id: int
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
class NapcatGroupBanNoticeData(NapcatNoticeData):
|
|
232
|
+
"""群禁言事件"""
|
|
233
|
+
|
|
234
|
+
discriminator_value: ClassVar[str] = "group_ban"
|
|
235
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_BAN_NOTICE
|
|
236
|
+
notice_type: str = "group_ban"
|
|
237
|
+
sub_type: str # ban/lift_ban
|
|
238
|
+
group_id: int
|
|
239
|
+
operator_id: int
|
|
240
|
+
user_id: int
|
|
241
|
+
duration: int # 禁言时长,单位秒
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class NapcatFriendAddNoticeData(NapcatNoticeData):
|
|
245
|
+
"""好友添加事件"""
|
|
246
|
+
|
|
247
|
+
discriminator_value: ClassVar[str] = "friend_add"
|
|
248
|
+
event_type: ClassVar[NapcatType] = NapcatType.FRIEND_ADD_NOTICE
|
|
249
|
+
notice_type: str = "friend_add"
|
|
250
|
+
user_id: int
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
class NapcatGroupRecallNoticeData(NapcatNoticeData):
|
|
254
|
+
"""群消息撤回事件"""
|
|
255
|
+
|
|
256
|
+
discriminator_value: ClassVar[str] = "group_recall"
|
|
257
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_RECALL_NOTICE
|
|
258
|
+
notice_type: str = "group_recall"
|
|
259
|
+
group_id: int
|
|
260
|
+
user_id: int
|
|
261
|
+
operator_id: int
|
|
262
|
+
message_id: int
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class NapcatFriendRecallNoticeData(NapcatNoticeData):
|
|
266
|
+
"""好友消息撤回事件"""
|
|
267
|
+
|
|
268
|
+
discriminator_value: ClassVar[str] = "friend_recall"
|
|
269
|
+
event_type: ClassVar[NapcatType] = NapcatType.FRIEND_RECALL_NOTICE
|
|
270
|
+
notice_type: str = "friend_recall"
|
|
271
|
+
user_id: int
|
|
272
|
+
message_id: int
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
class NapcatNotifyData(NapcatNoticeData):
|
|
276
|
+
"""通知事件(戳一戳/运气王/荣誉等)
|
|
277
|
+
|
|
278
|
+
使用 sub_type 字段进行三级分发
|
|
279
|
+
"""
|
|
280
|
+
|
|
281
|
+
discriminator_value: ClassVar[str] = "notify"
|
|
282
|
+
discriminator_field: ClassVar[str] = "sub_type"
|
|
283
|
+
event_type: ClassVar[NapcatType] = NapcatType.NOTICE
|
|
284
|
+
notice_type: str = "notify"
|
|
285
|
+
sub_type: str
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class NapcatPokeNotifyData(NapcatNotifyData):
|
|
289
|
+
"""戳一戳事件"""
|
|
290
|
+
|
|
291
|
+
discriminator_value: ClassVar[str] = "poke"
|
|
292
|
+
event_type: ClassVar[NapcatType] = NapcatType.POKE_NOTIFY
|
|
293
|
+
sub_type: str = "poke"
|
|
294
|
+
group_id: int | None = None # 私聊不存在
|
|
295
|
+
user_id: int
|
|
296
|
+
target_id: int
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
class NapcatLuckyKingNotifyData(NapcatNotifyData):
|
|
300
|
+
"""运气王事件"""
|
|
301
|
+
|
|
302
|
+
discriminator_value: ClassVar[str] = "lucky_king"
|
|
303
|
+
event_type: ClassVar[NapcatType] = NapcatType.LUCKY_KING_NOTIFY
|
|
304
|
+
sub_type: str = "lucky_king"
|
|
305
|
+
group_id: int
|
|
306
|
+
user_id: int # 红包发送者
|
|
307
|
+
target_id: int # 运气王
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class NapcatHonorNotifyData(NapcatNotifyData):
|
|
311
|
+
"""荣誉变更事件"""
|
|
312
|
+
|
|
313
|
+
discriminator_value: ClassVar[str] = "honor"
|
|
314
|
+
event_type: ClassVar[NapcatType] = NapcatType.HONOR_NOTIFY
|
|
315
|
+
sub_type: str = "honor"
|
|
316
|
+
group_id: int
|
|
317
|
+
honor_type: str # talkative/performer/emotion
|
|
318
|
+
user_id: int
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class NapcatGroupMsgEmojiLikeNoticeData(NapcatNoticeData):
|
|
322
|
+
"""群表情回应事件(NapCat/LLOneBot)"""
|
|
323
|
+
|
|
324
|
+
discriminator_value: ClassVar[str] = "group_msg_emoji_like"
|
|
325
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_EMOJI_LIKE_NOTICE
|
|
326
|
+
notice_type: str = "group_msg_emoji_like"
|
|
327
|
+
group_id: int
|
|
328
|
+
user_id: int
|
|
329
|
+
message_id: int
|
|
330
|
+
likes: list[EmojiLike]
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
class NapcatReactionNoticeData(NapcatNoticeData):
|
|
334
|
+
"""群表情回应事件(Lagrange)"""
|
|
335
|
+
|
|
336
|
+
discriminator_value: ClassVar[str] = "reaction"
|
|
337
|
+
event_type: ClassVar[NapcatType] = NapcatType.REACTION_NOTICE
|
|
338
|
+
notice_type: str = "reaction"
|
|
339
|
+
sub_type: str # add/remove
|
|
340
|
+
group_id: int
|
|
341
|
+
operator_id: int
|
|
342
|
+
message_id: int
|
|
343
|
+
code: str # 表情ID
|
|
344
|
+
count: int
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
class NapcatGroupEssenceNoticeData(NapcatNoticeData):
|
|
348
|
+
"""群精华消息事件"""
|
|
349
|
+
|
|
350
|
+
discriminator_value: ClassVar[str] = "essence"
|
|
351
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_ESSENCE_NOTICE
|
|
352
|
+
notice_type: str = "essence"
|
|
353
|
+
sub_type: str # add/delete
|
|
354
|
+
group_id: int
|
|
355
|
+
message_id: int
|
|
356
|
+
sender_id: int
|
|
357
|
+
operator_id: int
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
class NapcatGroupCardNoticeData(NapcatNoticeData):
|
|
361
|
+
"""群名片更新事件"""
|
|
362
|
+
|
|
363
|
+
discriminator_value: ClassVar[str] = "group_card"
|
|
364
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_CARD_NOTICE
|
|
365
|
+
notice_type: str = "group_card"
|
|
366
|
+
group_id: int
|
|
367
|
+
user_id: int
|
|
368
|
+
card_new: str
|
|
369
|
+
card_old: str
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
# ==================== 请求事件 ====================
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
class NapcatRequestData(NapcatData):
|
|
376
|
+
"""请求事件基类
|
|
377
|
+
|
|
378
|
+
使用 request_type 字段进行二级分发
|
|
379
|
+
"""
|
|
380
|
+
|
|
381
|
+
discriminator_value: ClassVar[str] = "request"
|
|
382
|
+
discriminator_field: ClassVar[str] = "request_type"
|
|
383
|
+
event_type: ClassVar[NapcatType] = NapcatType.REQUEST
|
|
384
|
+
post_type: str = "request"
|
|
385
|
+
request_type: str
|
|
386
|
+
flag: str
|
|
387
|
+
user_id: int
|
|
388
|
+
comment: str
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
class NapcatFriendRequestData(NapcatRequestData):
|
|
392
|
+
"""好友请求事件"""
|
|
393
|
+
|
|
394
|
+
discriminator_value: ClassVar[str] = "friend"
|
|
395
|
+
event_type: ClassVar[NapcatType] = NapcatType.FRIEND_REQUEST
|
|
396
|
+
request_type: str = "friend"
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class NapcatGroupRequestData(NapcatRequestData):
|
|
400
|
+
"""群请求事件"""
|
|
401
|
+
|
|
402
|
+
discriminator_value: ClassVar[str] = "group"
|
|
403
|
+
event_type: ClassVar[NapcatType] = NapcatType.GROUP_REQUEST
|
|
404
|
+
request_type: str = "group"
|
|
405
|
+
sub_type: str # add/invite
|
|
406
|
+
group_id: int
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
# ==================== 元事件 ====================
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
class NapcatMetaData(NapcatData):
|
|
413
|
+
"""元事件基类
|
|
414
|
+
|
|
415
|
+
使用 meta_event_type 字段进行二级分发
|
|
416
|
+
"""
|
|
417
|
+
|
|
418
|
+
discriminator_value: ClassVar[str] = "meta_event"
|
|
419
|
+
discriminator_field: ClassVar[str] = "meta_event_type"
|
|
420
|
+
event_type: ClassVar[NapcatType] = NapcatType.META
|
|
421
|
+
post_type: str = "meta_event"
|
|
422
|
+
meta_event_type: str
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
class NapcatLifecycleMetaData(NapcatMetaData):
|
|
426
|
+
"""生命周期元事件"""
|
|
427
|
+
|
|
428
|
+
discriminator_value: ClassVar[str] = "lifecycle"
|
|
429
|
+
event_type: ClassVar[NapcatType] = NapcatType.LIFECYCLE_META
|
|
430
|
+
meta_event_type: str = "lifecycle"
|
|
431
|
+
sub_type: str # enable/disable/connect
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
class NapcatHeartbeatMetaData(NapcatMetaData):
|
|
435
|
+
"""心跳元事件"""
|
|
436
|
+
|
|
437
|
+
discriminator_value: ClassVar[str] = "heartbeat"
|
|
438
|
+
event_type: ClassVar[NapcatType] = NapcatType.HEARTBEAT_META
|
|
439
|
+
meta_event_type: str = "heartbeat"
|
|
440
|
+
status: HeartbeatStatus
|
|
441
|
+
interval: int # 心跳间隔,单位毫秒
|