forked from Mrs4s/MiraiGo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentities.go
389 lines (322 loc) · 8.78 KB
/
entities.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
package client
import (
"github.com/pkg/errors"
"github.com/Mrs4s/MiraiGo/binary/jce"
"github.com/Mrs4s/MiraiGo/client/internal/auth"
"github.com/Mrs4s/MiraiGo/message"
)
var (
ErrAlreadyOnline = errors.New("already online")
ErrMemberNotFound = errors.New("member not found")
ErrNotExists = errors.New("not exists")
)
type (
LoginError int
QRCodeLoginState int
MemberPermission int
UserOnlineStatus int
ClientProtocol = auth.ProtocolType
LoginResponse struct {
Success bool
Code byte
Error LoginError
// Captcha info
CaptchaImage []byte
CaptchaSign []byte
// Unsafe device
VerifyUrl string
// SMS needed
SMSPhone string
// other error
ErrorMessage string
}
QRCodeLoginResponse struct {
State QRCodeLoginState
ImageData []byte
Sig []byte
LoginInfo *QRCodeLoginInfo
}
QRCodeLoginInfo struct {
tmpPwd []byte
tmpNoPicSig []byte
tgtQR []byte
}
FriendInfo struct {
Uin int64
Nickname string
Remark string
FaceId int16
// msgSeqList *utils.Cache
}
SummaryCardInfo struct {
Uin int64
Sex byte
Age uint8
Nickname string
Level int32
City string
Sign string
Mobile string
LoginDays int64
Qid string
VipLevel string
}
OtherClientInfo struct {
AppId int64
DeviceName string
DeviceKind string
}
FriendListResponse struct {
TotalCount int32
List []*FriendInfo
}
OtherClientStatusChangedEvent struct {
Client *OtherClientInfo
Online bool
}
GroupMuteEvent struct {
GroupCode int64
OperatorUin int64
TargetUin int64
Time int32
}
GroupMessageRecalledEvent struct {
GroupCode int64
OperatorUin int64
AuthorUin int64
MessageId int32
Time int32
}
FriendMessageRecalledEvent struct {
FriendUin int64
MessageId int32
Time int64
}
TempMessageEvent struct {
Message *message.TempMessage
Session *TempSessionInfo
}
GroupLeaveEvent struct {
Group *GroupInfo
Operator *GroupMemberInfo
}
MemberJoinGroupEvent struct {
Group *GroupInfo
Member *GroupMemberInfo
}
GroupNameUpdatedEvent struct {
Group *GroupInfo
OldName string
NewName string
OperatorUin int64
}
MemberCardUpdatedEvent struct {
Group *GroupInfo
OldCard string
Member *GroupMemberInfo
}
INotifyEvent interface {
From() int64
Content() string
}
MemberLeaveGroupEvent struct {
Group *GroupInfo
Member *GroupMemberInfo
Operator *GroupMemberInfo
}
MemberPermissionChangedEvent struct {
Group *GroupInfo
Member *GroupMemberInfo
OldPermission MemberPermission
NewPermission MemberPermission
}
ClientDisconnectedEvent struct {
Message string
}
NewFriendRequest struct {
RequestId int64
Message string
RequesterUin int64
RequesterNick string
client *QQClient
}
ServerUpdatedEvent struct {
Servers []jce.SsoServerInfo
}
NewFriendEvent struct {
Friend *FriendInfo
}
OfflineFileEvent struct {
FileName string
FileSize int64
Sender int64
DownloadUrl string
}
GroupDisbandEvent struct {
Group *GroupInfo
Time int64
Operator *GroupMemberInfo
}
DeleteFriendEvent struct {
Uin int64
Nickname string
}
// GroupDigest 群精华消息
GroupDigest struct {
GroupCode int64 `json:"group_code,string"`
MessageID uint32 `json:"msg_seq"`
InternalMessageID uint32 `json:"msg_random"`
SenderUin int64 `json:"sender_uin,string"`
SenderNick string `json:"sender_nick"`
SenderTime int64 `json:"sender_time"`
AddDigestUin int64 `json:"add_digest_uin,string"`
AddDigestNick string `json:"add_digest_nick"`
AddDigestTime int64 `json:"add_digest_time"`
}
// GroupDigestEvent 群精华消息 不知道tx为什么搞两种名字
GroupDigestEvent struct {
GroupCode int64
MessageID int32
InternalMessageID int32
OperationType int32 // 1 -> 设置精华消息, 2 -> 移除精华消息
OperateTime uint32
SenderUin int64
OperatorUin int64
SenderNick string
OperatorNick string
}
GuildMessageReactionsUpdatedEvent struct {
OperatorId uint64 // OperatorId 操作者TinyId, 删除贴表情的事件下不会有值
EmojiId int32 // EmojiId 被贴的表情, 只有自身消息被贴表情才会有值
GuildId uint64
ChannelId uint64
MessageId uint64
// MessageSenderUin int64 // MessageSenderUin 被贴表情的消息发送者QQ号
CurrentReactions []*message.GuildMessageEmojiReaction
}
GuildChannelUpdatedEvent struct {
OperatorId uint64
GuildId uint64
ChannelId uint64
OldChannelInfo *ChannelInfo
NewChannelInfo *ChannelInfo
}
GuildMessageRecalledEvent struct {
OperatorId uint64
GuildId uint64
ChannelId uint64
MessageId uint64
RecallTime int64
}
GuildChannelOperationEvent struct {
OperatorId uint64
GuildId uint64
ChannelInfo *ChannelInfo
}
MemberJoinGuildEvent struct {
Guild *GuildInfo
Member *GuildMemberInfo
}
OcrResponse struct {
Texts []*TextDetection `json:"texts"`
Language string `json:"language"`
}
TextDetection struct {
Text string `json:"text"`
Confidence int32 `json:"confidence"`
Coordinates []*Coordinate `json:"coordinates"`
}
Coordinate struct {
X int32 `json:"x"`
Y int32 `json:"y"`
}
AtAllRemainInfo struct {
CanAtAll bool `json:"can_at_all"`
RemainAtAllCountForGroup uint32 `json:"remain_at_all_count_for_group"`
RemainAtAllCountForUin uint32 `json:"remain_at_all_count_for_uin"`
}
groupMemberListResponse struct {
NextUin int64
list []*GroupMemberInfo
}
groupMessageReceiptEvent struct {
Rand int32
Seq int32
Msg *message.GroupMessage
}
bigDataSessionInfo struct {
SigSession []byte
SessionKey []byte
}
// unit is an alias for struct{}, like `()` in rust
unit = struct{}
)
//go:generate stringer -type=LoginError
const (
NeedCaptcha LoginError = 1
OtherLoginError LoginError = 3
UnsafeDeviceError LoginError = 4
SMSNeededError LoginError = 5
TooManySMSRequestError LoginError = 6
SMSOrVerifyNeededError LoginError = 7
SliderNeededError LoginError = 8
UnknownLoginError LoginError = -1
QRCodeImageFetch QRCodeLoginState = 1
QRCodeWaitingForScan QRCodeLoginState = 2
QRCodeWaitingForConfirm QRCodeLoginState = 3
QRCodeTimeout QRCodeLoginState = 4
QRCodeConfirmed QRCodeLoginState = 5
QRCodeCanceled QRCodeLoginState = 6
StatusOnline UserOnlineStatus = 11 // 在线
StatusOffline UserOnlineStatus = 21 // 离线
StatusAway UserOnlineStatus = 31 // 离开
StatusInvisible UserOnlineStatus = 41 // 隐身
StatusBusy UserOnlineStatus = 50 // 忙
StatusBattery UserOnlineStatus = 1000 // 当前电量
StatusListening UserOnlineStatus = 1028 // 听歌中
StatusConstellation UserOnlineStatus = 1040 // 星座运势
StatusWeather UserOnlineStatus = 1030 // 今日天气
StatusMeetSpring UserOnlineStatus = 1069 // 遇见春天
StatusTimi UserOnlineStatus = 1027 // Timi中
StatusEatChicken UserOnlineStatus = 1064 // 吃鸡中
StatusLoving UserOnlineStatus = 1051 // 恋爱中
StatusWangWang UserOnlineStatus = 1053 // 汪汪汪
StatusCookedRice UserOnlineStatus = 1019 // 干饭中
StatusStudy UserOnlineStatus = 1018 // 学习中
StatusStayUp UserOnlineStatus = 1032 // 熬夜中
StatusPlayBall UserOnlineStatus = 1050 // 打球中
StatusSignal UserOnlineStatus = 1011 // 信号弱
StatusStudyOnline UserOnlineStatus = 1024 // 在线学习
StatusGaming UserOnlineStatus = 1017 // 游戏中
StatusVacationing UserOnlineStatus = 1022 // 度假中
StatusWatchingTV UserOnlineStatus = 1021 // 追剧中
StatusFitness UserOnlineStatus = 1020 // 健身中
Owner MemberPermission = 1
Administrator MemberPermission = 2
Member MemberPermission = 3
Unset = auth.Unset
AndroidPhone = auth.AndroidPhone
AndroidWatch = auth.AndroidWatch
MacOS = auth.MacOS
QiDian = auth.QiDian
IPad = auth.IPad
AndroidPad = auth.AndroidPad
)
func (r *UserJoinGroupRequest) Accept() {
r.client.SolveGroupJoinRequest(r, true, false, "")
}
func (r *UserJoinGroupRequest) Reject(block bool, reason string) {
r.client.SolveGroupJoinRequest(r, false, block, reason)
}
func (r *GroupInvitedRequest) Accept() {
r.client.SolveGroupJoinRequest(r, true, false, "")
}
func (r *GroupInvitedRequest) Reject(block bool, reason string) {
r.client.SolveGroupJoinRequest(r, false, block, reason)
}
func (r *NewFriendRequest) Accept() {
r.client.SolveFriendRequest(r, true)
}
func (r *NewFriendRequest) Reject() {
r.client.SolveFriendRequest(r, false)
}