/
WebQQ.event.go
242 lines (221 loc) · 7 KB
/
WebQQ.event.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
package webqq
import (
"encoding/json"
"fmt"
"github.com/pa001024/reflex/util"
)
// 解析事件
func (data RawEvent) ParseEvent(poll_type string) (v Event, err error) {
util.TRACE.Logf("[RawEvent] %s", string(data))
switch poll_type {
case "message":
v = &EventMessage{}
case "group_message":
v = &EventGroupMessage{}
case "discu_message":
v = &EventDiscuMessage{}
case "buddies_status_change":
v = &EventBuddiesStatusChange{}
case "group_web_message":
v = &EventGroupWebMessage{}
case "input_notify":
v = &EventInputNotify{}
case "filesrv_transfer":
v = &EventFileSrvTransfer{}
case "file_message":
v = &EventFileMessage{}
case "av_refuse":
v = &EventAvRefuse{}
case "shake_message":
v = &EventShakeMessage{}
case "push_offfile":
v = &EventPushOffFile{}
case "system_message":
v = &EventSystemMessage{}
case "sys_g_msg":
v = &EventSysGroupMessage{}
default:
err = fmt.Errorf("Unsupport poll_type: %v", poll_type)
return
}
err = json.Unmarshal(data, v)
return
}
type RawEvent json.RawMessage
type Event interface{}
// "poll_type": "message"
type EventMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
Time uint64 `json:"time"`
Content Content `json:"content"`
}
// "poll_type": "group_message"
type EventGroupMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
GroupCode GCode `json:"group_code"`
SendUin Uin `json:"send_uin"`
Seq uint64 `json:"seq"`
Time uint64 `json:"time"`
InfoSeq uint64 `json:"info_seq"` // 群号
Content Content `json:"content"`
}
// "poll_type": "discu_message"
type EventDiscuMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
DiscuId DiscuId `json:"did"`
SendUin Uin `json:"send_uin"`
Seq uint64 `json:"seq"`
Time uint64 `json:"time"`
InfoSeq uint64 `json:"info_seq"` // 讨论组号
Content Content `json:"content"`
}
// "poll_type": "buddies_status_change"
type EventBuddiesStatusChange struct {
Uin Uin `json:"uin"`
Status uint32 `json:"status"`
ClientType uint32 `json:"client_type"`
}
// "poll_type": "group_web_message"
type EventGroupWebMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
GroupType uint32 `json:"group_type"`
Ver uint32 `json:"ver"`
GroupCode GCode `json:"group_code"`
SendUin Uin `json:"send_uin"`
Xml string `json:"xml"`
}
// "poll_type": "input_notify"
type EventInputNotify struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
}
// "poll_type": "filesrv_transfer"
type EventFileSrvTransfer struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
LcId uint32 `json:"lc_id"`
Type uint32 `json:"type"`
Operation uint32 `json:"operation"`
Now uint32 `json:"now"`
FileCount uint32 `json:"file_count"`
FileInfos struct {
FileName string `json:"file_name"`
ProId uint32 `json:"pro_id"`
FileStatus uint32 `json:"file_status"`
} `json:"file_infos"`
}
// "poll_type": "file_message"
type EventFileMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
Mode string `json:"mode"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
Type uint32 `json:"type"`
SessionId uint32 `json:"session_id"`
Time uint32 `json:"time"`
InetIp uint32 `json:"inet_ip"`
}
// "poll_type": "av_refuse"
type EventAvRefuse struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
Type uint32 `json:"type"`
SessionId uint32 `json:"session_id"`
Time uint32 `json:"time"`
Longconn string `json:"longconn"`
}
// "poll_type": "shake_message"
type EventShakeMessage struct {
FromUin Uin `json:"from_uin"`
ToUin Uin `json:"to_uin"`
MsgId uint32 `json:"msg_id"`
MsgId2 uint32 `json:"msg_id2"`
MsgType uint32 `json:"msg_type"`
ReplyIp uint32 `json:"reply_ip"`
}
// "poll_type": "push_offfile"
type EventPushOffFile struct {
FromUin Uin `json:"from_uin"`
MsgId uint32 `json:"msg_id"`
Rkey string `json:"rkey"`
Name string `json:"name"`
Ip string `json:"ip"`
Port uint32 `json:"port"`
Size uint32 `json:"size"`
ExpireTime uint32 `json:"expire_time"`
Time uint32 `json:"time"`
}
type SystemMessageType string
const (
AddedBuddySig SystemMessageType = "added_buddy_sig"
AddedBuddyNosig = "added_buddy_nosig"
VerifyPassAdd = "verify_pass_add"
VerifyPass = "verify_pass"
VerifyRequired = "verify_required"
VerifyRejected = "verify_rejected"
)
// "poll_type": "system_message"
type EventSystemMessage struct {
Type SystemMessageType `json:"type"`
FromUin Uin `json:"from_uin"`
Stat uint32 `json:"stat"`
ClientType ClientType `json:"client_type"`
GroupId GCode `json:"group_id"`
Msg string `json:"msg"`
Account Account `json:"account"`
Uiuin Uin `json:"uiuin"`
}
type SysGroupMessageType string
const (
GroupJoin SysGroupMessageType = "group_join"
GroupLeave = "group_leave"
GroupRequestJoin = "group_request_join"
GroupRequestJoinAgree = "group_request_join_agree"
GroupRequestJoinDeny = "group_request_join_deny"
GroupAdminOp = "group_admin_op"
GroupCreate = "group_create"
)
// "poll_type": "sys_g_msg"
type EventSysGroupMessage struct {
Type SysGroupMessageType `json:"type"`
NewMember string `json:"new_member"`
OldMember string `json:"old_member"`
GCode GCode `json:"gcode"`
RequestUin Uin `json:"request_uin"`
OpType string `json:"op_type"` // 0,2:取消管理员 3:成为管理员 255:群主(转让)
// TOldMember string `json:"t_old_member"`
// TGCode GCode `json:"t_gcode"`
// TNewMember string `json:"t_new_member"`
// TRequestUin Uin `json:"t_request_uin"`
}