@@ -8,10 +8,12 @@ import (
8
8
)
9
9
10
10
type MediaMsg struct {
11
- XMLName xml.Name `xml:"msg"`
12
- Image Image `xml:"img,omitempty"`
13
- Video Video `xml:"videomsg,omitempty"`
14
- App App `xml:"appmsg,omitempty"`
11
+ XMLName xml.Name `xml:"msg"`
12
+ Image Image `xml:"img,omitempty"`
13
+ Video Video `xml:"videomsg,omitempty"`
14
+ App App `xml:"appmsg,omitempty"`
15
+ Emoji Emoji `xml:"emoji,omitempty"`
16
+ Location Location `xml:"location,omitempty"`
15
17
}
16
18
17
19
type Image struct {
@@ -70,9 +72,63 @@ type App struct {
70
72
FinderFeed * FinderFeed `xml:"finderFeed,omitempty"` // type 51 视频号
71
73
ReferMsg * ReferMsg `xml:"refermsg,omitempty"` // type 57 引用
72
74
PatMsg * PatMsg `xml:"patMsg,omitempty"` // type 62 拍一拍
75
+ PatInfo * PatInfo `xml:"patinfo,omitempty"` // type 62 拍一拍 v2
76
+ FinderLive * FinderLive `xml:"finderLive,omitempty"` // type 63 视频号直播
73
77
WCPayInfo * WCPayInfo `xml:"wcpayinfo,omitempty"` // type 2000 微信转账
74
78
}
75
79
80
+ type Emoji struct {
81
+ FromUsername string `xml:"fromusername,attr"`
82
+ ToUsername string `xml:"tousername,attr"`
83
+ Type string `xml:"type,attr"`
84
+ IdBuffer string `xml:"idbuffer,attr"`
85
+ Md5 string `xml:"md5,attr"`
86
+ Len string `xml:"len,attr"`
87
+ CdnURL string `xml:"cdnurl,attr"`
88
+ AesKey string `xml:"aeskey,attr"`
89
+ Width string `xml:"width,attr"`
90
+ Height string `xml:"height,attr"`
91
+ // ProductId string `xml:"productid,attr"`
92
+ // AndroidMd5 string `xml:"androidmd5,attr"`
93
+ // AndroidLen string `xml:"androidlen,attr"`
94
+ // S60v3Md5 string `xml:"s60v3md5,attr"`
95
+ // S60v3Len string `xml:"s60v3len,attr"`
96
+ // S60v5Md5 string `xml:"s60v5md5,attr"`
97
+ // S60v5Len string `xml:"s60v5len,attr"`
98
+ // DesignerId string `xml:"designerid,attr"`
99
+ // ThumbUrl string `xml:"thumburl,attr"`
100
+ // EncryptUrl string `xml:"encrypturl,attr"`
101
+ // ExternUrl string `xml:"externurl,attr"`
102
+ // ExternMd5 string `xml:"externmd5,attr"`
103
+ // TpUrl string `xml:"tpurl,attr"`
104
+ // TpAuthKey string `xml:"tpauthkey,attr"`
105
+ // AttachedText string `xml:"attachedtext,attr"`
106
+ // AttachedTextColor string `xml:"attachedtextcolor,attr"`
107
+ // LensId string `xml:"lensid,attr"`
108
+ // EmojiAttr string `xml:"emojiattr,attr"`
109
+ // LinkId string `xml:"linkid,attr"`
110
+ // Desc string `xml:"desc,attr"`
111
+ }
112
+
113
+ type Location struct {
114
+ X string `xml:"x,attr"`
115
+ Y string `xml:"y,attr"`
116
+ Scale string `xml:"scale,attr"`
117
+ Label string `xml:"label,attr"`
118
+ MapType string `xml:"maptype,attr"`
119
+ Adcode string `xml:"adcode,attr"`
120
+ CityName string `xml:"cityname,attr"`
121
+ // PoiName string `xml:"poiname,attr"`
122
+ // PoiId string `xml:"poiid,attr"`
123
+ // BuildingId string `xml:"buildingId,attr"`
124
+ // FloorName string `xml:"floorName,attr"`
125
+ // PoiCategoryTips string `xml:"poiCategoryTips,attr"`
126
+ // PoiBusinessHour string `xml:"poiBusinessHour,attr"`
127
+ // PoiPhone string `xml:"poiPhone,attr"`
128
+ // PoiPriceTips string `xml:"poiPriceTips,attr"`
129
+ // IsFromPoiList string `xml:"isFromPoiList,attr"`
130
+ }
131
+
76
132
// ReferMsg 表示引用消息
77
133
type ReferMsg struct {
78
134
Type int64 `xml:"type"`
@@ -153,27 +209,50 @@ type DataItem struct {
153
209
MessageUUID string `xml:"messageuuid,omitempty"`
154
210
FromNewMsgID string `xml:"fromnewmsgid,omitempty"`
155
211
212
+ // 链接
213
+ Link string `xml:"link,omitempty"`
214
+
215
+ // 音乐
216
+ StreamWebURL string `xml:"streamweburl,omitempty"`
217
+
218
+ // 位置
219
+ Location DataItemLocation `xml:"location,omitempty"`
220
+
156
221
// 套娃合并转发
157
222
DataTitle string `xml:"datatitle,omitempty"`
158
223
RecordXML * RecordXML `xml:"recordxml,omitempty"`
159
224
}
160
225
226
+ type DataItemLocation struct {
227
+ Lat string `xml:"lat,attr"`
228
+ Lng string `xml:"lng,attr"`
229
+ Scale string `xml:"scale,attr"`
230
+ Label string `xml:"label,attr"`
231
+ PoiName string `xml:"poiname,attr"`
232
+ }
233
+
161
234
type RecordXML struct {
162
235
RecordInfo RecordInfo `xml:"recordinfo,omitempty"`
163
236
}
164
237
165
- func (r * RecordInfo ) String (title , host string ) string {
238
+ func (r * RecordInfo ) String (_type , title , host string ) string {
166
239
buf := strings.Builder {}
167
240
if title == "" {
168
241
title = r .Title
169
242
}
170
- buf .WriteString (fmt .Sprintf ("[合并转发|%s]\n " , title ))
243
+ if title == "" {
244
+ title = strings .TrimSpace (strings .ReplaceAll (r .Desc , "\n " , " " ))
245
+ if len (title ) > 80 {
246
+ title = title [:80 ] + "..."
247
+ }
248
+ }
249
+ buf .WriteString (fmt .Sprintf ("[%s|%s]\n " , _type , title ))
171
250
for _ , item := range r .DataList .DataItems {
172
251
buf .WriteString (fmt .Sprintf (" %s %s\n " , item .SourceName , item .SourceTime ))
173
252
174
253
// 套娃合并转发
175
254
if item .DataType == "17" && item .RecordXML != nil {
176
- content := item .RecordXML .RecordInfo .String (item .DataTitle , host )
255
+ content := item .RecordXML .RecordInfo .String (_type , item .DataTitle , host )
177
256
if content != "" {
178
257
for _ , line := range strings .Split (content , "\n " ) {
179
258
buf .WriteString (fmt .Sprintf (" %s\n " , line ))
@@ -182,14 +261,44 @@ func (r *RecordInfo) String(title, host string) string {
182
261
continue
183
262
}
184
263
185
- switch item .DataFmt {
186
- case "pic" , "jpg" :
264
+ switch item .DataType {
265
+ case "2" :
266
+ // 图片
187
267
buf .WriteString (fmt .Sprintf (" \n " , host , item .FullMD5 ))
268
+ case "4" :
269
+ //视频
270
+ buf .WriteString (fmt .Sprintf (" \n " , host , item .FullMD5 ))
271
+ case "8" :
272
+ // 文件
273
+ // FIXME 笔记的第一条是 htm 数据,暂时跳过处理
274
+ if item .DataFmt == ".htm" {
275
+ continue
276
+ }
277
+ buf .WriteString (fmt .Sprintf (" [文件|%s](http://%s/file/%s)\n " , item .DataTitle , host , item .FullMD5 ))
278
+ case "5" :
279
+ // Link
280
+ buf .WriteString (fmt .Sprintf (" [链接|%s](%s)\n " , item .DataTitle , item .Link ))
281
+ case "6" :
282
+ // Location
283
+ buf .WriteString (fmt .Sprintf (" [位置|%s]\n " , item .Location .PoiName ))
284
+ case "22" :
285
+ // 视频号
286
+ buf .WriteString (fmt .Sprintf (" [视频号|%s]\n " , strings .TrimSpace (strings .ReplaceAll (item .DataDesc , "\n " , " " ))))
287
+ case "23" :
288
+ // 视频号直播
289
+ buf .WriteString (fmt .Sprintf (" [视频号直播|%s]\n " , strings .TrimSpace (strings .ReplaceAll (item .DataDesc , "\n " , " " ))))
290
+ case "32" :
291
+ // 音乐
292
+ buf .WriteString (fmt .Sprintf (" [音乐|%s](%s)\n " , item .DataTitle , item .StreamWebURL ))
293
+ case "37" :
294
+ // 动画表情
295
+ buf .WriteString (" [动画表情]\n " )
188
296
default :
189
297
for _ , line := range strings .Split (item .DataDesc , "\n " ) {
190
298
buf .WriteString (fmt .Sprintf (" %s\n " , line ))
191
299
}
192
300
}
301
+
193
302
buf .WriteString ("\n " )
194
303
}
195
304
return buf .String ()
@@ -202,6 +311,16 @@ type PatMsg struct {
202
311
Records Records `xml:"records"` // 拍一拍记录
203
312
}
204
313
314
+ // PatInfo 拍一拍 v2
315
+ type PatInfo struct {
316
+ FromUsername string `xml:"fromusername"`
317
+ ChatUsername string `xml:"chatusername"`
318
+ PattedUsername string `xml:"pattedusername"`
319
+ PatSuffix string `xml:"patsuffix"`
320
+ PatSuffixVersion int `xml:"patsuffixversion"`
321
+ Template string `xml:"template"`
322
+ }
323
+
205
324
// Records 拍一拍记录集合
206
325
type Records struct {
207
326
Record []PatRecord `xml:"record"` // 拍一拍记录列表
@@ -283,10 +402,49 @@ type FinderMegaVideo struct {
283
402
ObjectNonceID string `xml:"objectNonceId"`
284
403
}
285
404
405
+ type FinderLive struct {
406
+ FinderLiveID string `xml:"finderLiveID"`
407
+ FinderUsername string `xml:"finderUsername"`
408
+ FinderObjectID string `xml:"finderObjectID"`
409
+ FinderNonceID string `xml:"finderNonceID"`
410
+ Nickname string `xml:"nickname"`
411
+ HeadURL string `xml:"headUrl"`
412
+ Desc string `xml:"desc"`
413
+ LiveStatus int `xml:"liveStatus"`
414
+ LiveSourceTypeStr string `xml:"liveSourceTypeStr"`
415
+ ExtFlag int `xml:"extFlag"`
416
+ LiveSecondaryDeviceFlagStr string `xml:"liveSecondaryDeviceFlagStr"`
417
+ LiveFlag int `xml:"liveFlag"`
418
+ AuthIconURL string `xml:"authIconUrl"`
419
+ AuthIconTypeStr string `xml:"authIconTypeStr"`
420
+ BindType int `xml:"bindType"`
421
+ BizUsername string `xml:"bizUsername"`
422
+ BizNickname string `xml:"bizNickname"`
423
+ ChargeFlag int `xml:"chargeFlag"`
424
+ ReplayStatus int `xml:"replayStatus"`
425
+ SpamLiveExtFlagString string `xml:"spamLiveExtFlagString"`
426
+ EnterSessionID string `xml:"enterSessionId"`
427
+ LiveMode int `xml:"liveMode"`
428
+ LiveSubMode int `xml:"liveSubMode"`
429
+ Media FinderLiveMedia `xml:"media"`
430
+ ShareScene int `xml:"shareScene"`
431
+ }
432
+
433
+ type FinderLiveMedia struct {
434
+ CoverURL FinderLiveMediaCoverURL `xml:"coverUrl"`
435
+ Height int `xml:"height"`
436
+ Width int `xml:"width"`
437
+ }
438
+
439
+ type FinderLiveMediaCoverURL struct {
440
+ Text string `xml:",cdata"`
441
+ }
442
+
286
443
type SysMsg struct {
287
444
Type string `xml:"type,attr"`
288
445
DelChatRoomMember * DelChatRoomMember `xml:"delchatroommember,omitempty"`
289
446
SysMsgTemplate * SysMsgTemplate `xml:"sysmsgtemplate,omitempty"`
447
+ RevokeMsg * RevokeMsg `xml:"revokemsg,omitempty"`
290
448
}
291
449
292
450
// 第一种消息类型:删除群成员/二维码邀请
@@ -296,6 +454,11 @@ type DelChatRoomMember struct {
296
454
Link QRLink `xml:"link"`
297
455
}
298
456
457
+ type RevokeMsg struct {
458
+ Content string `xml:"content"`
459
+ RevokeTime int `xml:"revoketime"`
460
+ }
461
+
299
462
type QRLink struct {
300
463
Scene string `xml:"scene"`
301
464
Text string `xml:"text"`
@@ -345,8 +508,11 @@ type Member struct {
345
508
}
346
509
347
510
func (s * SysMsg ) String () string {
348
- if s .Type == "delchatroommember" {
511
+ switch s .Type {
512
+ case "delchatroommember" :
349
513
return s .DelChatRoomMemberString ()
514
+ case "revokemsg" :
515
+ return s .RevokeMsg .Content
350
516
}
351
517
return s .SysMsgTemplateString ()
352
518
}
0 commit comments