forked from iyear/biligo-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsg.go
1911 lines (1618 loc) · 39.6 KB
/
msg.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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package live
import (
"encoding/binary"
"encoding/json"
)
// TODO msg注释移到struct上
type Transport struct {
Msg Msg
Error error
}
type Msg interface {
Cmd() string
Raw() []byte
}
type base struct {
raw []byte
}
func getData(raw []byte) json.RawMessage {
var d struct {
Data json.RawMessage `json:"data"`
}
if err := json.Unmarshal(raw, &d); err != nil {
return []byte{}
}
return d.Data
}
//
type MsgGeneral struct {
base
}
func (m *MsgGeneral) Cmd() string {
var cmd struct {
CMD string `json:"cmd"`
}
if err := json.Unmarshal(m.raw, &cmd); err != nil {
return ""
}
return cmd.CMD
}
func (m *MsgGeneral) Raw() []byte {
return m.raw
}
//
type MsgHeartbeatReply struct {
base
}
func (m *MsgHeartbeatReply) Cmd() string {
return "HEARTBEAT_REPLY"
}
func (m *MsgHeartbeatReply) Raw() []byte {
return m.raw
}
func (m *MsgHeartbeatReply) GetHot() int {
return int(binary.BigEndian.Uint32(m.raw))
}
//
// MsgDanmaku 弹幕消息
type MsgDanmaku struct {
base
}
func (m *MsgDanmaku) Cmd() string {
return cmdDanmaku
}
func (m *MsgDanmaku) Raw() []byte {
return m.raw
}
type Danmaku struct {
SendMode int `json:"send_mode"`
SendFontSize int `json:"send_font_size"`
DanmakuColor int64 `json:"danmaku_color"`
Time int64 `json:"time"`
DMID int64 `json:"dmid"`
MsgType int `json:"msg_type"`
Bubble string `json:"bubble"`
Content string `json:"content"`
MID int64 `json:"mid"`
Uname string `json:"uname"`
RoomAdmin int `json:"room_admin"`
Vip int `json:"vip"`
SVip int `json:"svip"`
Rank int `json:"rank"`
MobileVerify int `json:"mobile_verify"`
UnameColor string `json:"uname_color"`
MedalName string `json:"medal_name"`
UpName string `json:"up_name"`
MedalLevel int `json:"medal_level"`
UserLevel int `json:"user_level"`
}
func (m *MsgDanmaku) Parse() (*Danmaku, error) {
var t map[string]interface{}
if err := json.Unmarshal(m.raw, &t); err != nil {
return nil, err
}
info := t["info"]
var dm = &Danmaku{}
l := len(info.([]interface{}))
if l >= 1 {
h := info.([]interface{})[0].([]interface{})
dm.SendMode = int(h[1].(float64))
dm.SendFontSize = int(h[2].(float64))
dm.DanmakuColor = int64(h[3].(float64))
dm.Time = int64(h[4].(float64))
dm.DMID = int64(h[5].(float64))
dm.MsgType = int(h[10].(float64))
dm.Bubble = h[11].(string)
}
if l >= 2 {
dm.Content = info.([]interface{})[1].(string)
}
if l >= 3 {
h := info.([]interface{})[2].([]interface{})
dm.MID = int64(h[0].(float64))
dm.Uname = h[1].(string)
dm.RoomAdmin = int(h[2].(float64))
dm.Vip = int(h[3].(float64))
dm.SVip = int(h[4].(float64))
dm.Rank = int(h[5].(float64))
dm.MobileVerify = int(h[6].(float64))
dm.UnameColor = h[7].(string)
}
if l >= 4 {
h := info.([]interface{})[3].([]interface{})
l2 := len(h)
if l2 >= 1 {
dm.MedalLevel = int(h[0].(float64))
}
if l2 >= 2 {
dm.MedalName = h[1].(string)
}
if l2 >= 3 {
dm.UpName = h[2].(string)
}
}
if l >= 5 {
dm.UserLevel = int(info.([]interface{})[4].([]interface{})[0].(float64))
}
return dm, nil
}
//
// MsgSendGift 投喂礼物
type MsgSendGift struct {
base
}
func (m *MsgSendGift) Cmd() string {
return cmdSendGift
}
func (m *MsgSendGift) Raw() []byte {
return m.raw
}
type SendGift struct {
Action string `json:"action"`
BatchComboID string `json:"batch_combo_id"`
BatchComboSend struct {
Action string `json:"action"`
BatchComboID string `json:"batch_combo_id"`
BatchComboNum int `json:"batch_combo_num"`
BlindGift interface{} `json:"blind_gift"`
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
GiftNum int `json:"gift_num"`
SendMaster interface{} `json:"send_master"`
Uid int `json:"uid"`
Uname string `json:"uname"`
} `json:"batch_combo_send"`
BeatID string `json:"beatId"`
BizSource string `json:"biz_source"`
BlindGift interface{} `json:"blind_gift"`
BroadcastID int64 `json:"broadcast_id"`
CoinType string `json:"coin_type"`
ComboResourcesID int64 `json:"combo_resources_id"`
ComboSend struct {
Action string `json:"action"`
ComboID string `json:"combo_id"`
ComboNum int `json:"combo_num"`
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
GiftNum int `json:"gift_num"`
SendMaster interface{} `json:"send_master"`
UID int64 `json:"uid"`
Uname string `json:"uname"`
} `json:"combo_send"`
ComboStayTime int64 `json:"combo_stay_time"`
ComboTotalCoin int `json:"combo_total_coin"`
CritProb int `json:"crit_prob"`
Demarcation int `json:"demarcation"`
DiscountPrice int `json:"discount_price"`
Dmscore int `json:"dmscore"`
Draw int `json:"draw"`
Effect int `json:"effect"`
EffectBlock int `json:"effect_block"`
Face string `json:"face"`
FloatScResourceID int64 `json:"float_sc_resource_id"`
GiftID int64 `json:"giftId"`
GiftName string `json:"giftName"`
GiftType int `json:"giftType"`
Gold int `json:"gold"`
GuardLevel int `json:"guard_level"`
IsFirst bool `json:"is_first"`
IsSpecialBatch int `json:"is_special_batch"`
Magnification float64 `json:"magnification"`
MedalInfo struct {
AnchorRoomid int `json:"anchor_roomid"`
AnchorUname string `json:"anchor_uname"`
GuardLevel int `json:"guard_level"`
IconID int64 `json:"icon_id"`
IsLighted int `json:"is_lighted"`
MedalColor int `json:"medal_color"`
MedalColorBorder int64 `json:"medal_color_border"`
MedalColorEnd int64 `json:"medal_color_end"`
MedalColorStart int64 `json:"medal_color_start"`
MedalLevel int `json:"medal_level"`
MedalName string `json:"medal_name"`
Special string `json:"special"`
TargetID int `json:"target_id"`
} `json:"medal_info"`
NameColor string `json:"name_color"`
Num int `json:"num"`
OriginalGiftName string `json:"original_gift_name"`
Price int `json:"price"`
Rcost int `json:"rcost"`
Remain int `json:"remain"`
Rnd string `json:"rnd"`
SendMaster interface{} `json:"send_master"`
Silver int `json:"silver"`
Super int `json:"super"`
SuperBatchGiftNum int `json:"super_batch_gift_num"`
SuperGiftNum int `json:"super_gift_num"`
SvgaBlock int `json:"svga_block"`
TagImage string `json:"tag_image"`
TID string `json:"tid"`
Timestamp int64 `json:"timestamp"`
TopList interface{} `json:"top_list"`
TotalCoin int `json:"total_coin"`
UID int64 `json:"uid"`
Uname string `json:"uname"`
}
func (m *MsgSendGift) Parse() (*SendGift, error) {
var r = &SendGift{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgComboSend 连击礼物
type MsgComboSend struct {
base
}
func (m *MsgComboSend) Cmd() string {
return cmdComboSend
}
func (m *MsgComboSend) Raw() []byte {
return m.raw
}
//
// MsgFansUpdate 粉丝数量改变
type MsgFansUpdate struct {
base
}
func (m *MsgFansUpdate) Cmd() string {
return cmdRoomRealTimeMessageUpdate
}
func (m *MsgFansUpdate) Raw() []byte {
return m.raw
}
type FansUpdate struct {
// {
// "fans_club": 49182,
// "roomid": 545068,
// "fans": 1384297,
// "red_notice": -1
// }
FansClub int `json:"fans_club"`
RoomID int64 `json:"roomid"`
Fans int `json:"fans"`
RedNotice int `json:"red_notice"`
}
func (m *MsgFansUpdate) Parse() (*FansUpdate, error) {
var f = &FansUpdate{}
if err := json.Unmarshal(getData(m.raw), &f); err != nil {
return nil, err
}
return f, nil
}
//
// MsgOnlineRankCount 高能榜数量更新
type MsgOnlineRankCount struct {
base
}
func (m *MsgOnlineRankCount) Cmd() string {
return cmdOnlineRankCount
}
func (m *MsgOnlineRankCount) Raw() []byte {
return m.raw
}
func (m *MsgOnlineRankCount) GetCount() int {
var c struct {
Count int `json:"count"`
}
if err := json.Unmarshal(getData(m.raw), &c); err != nil {
return -1
}
return c.Count
}
//
// MsgSuperChatMessage 醒目留言
type MsgSuperChatMessage struct {
base
}
func (m *MsgSuperChatMessage) Cmd() string {
return cmdSuperChatMessage
}
func (m *MsgSuperChatMessage) Raw() []byte {
return m.raw
}
type SuperChatMessage struct {
BackgroundBottomColor string `json:"background_bottom_color"`
Token string `json:"token"`
BackgroundColorEnd string `json:"background_color_end"`
BackgroundImage string `json:"background_image"`
BackgroundIcon string `json:"background_icon"`
BackgroundPriceColor string `json:"background_price_color"`
DmScore int `json:"dmscore"`
ID int64 `json:"id"`
UserInfo struct {
UserLevel int `json:"user_level"`
FaceFrame string `json:"face_frame"`
GuardLevel int `json:"guard_level"`
LevelColor string `json:"level_color"`
Manager int `json:"manager"`
Uname string `json:"uname"`
Title string `json:"title"`
Face string `json:"face"`
IsMainVip int `json:"is_main_vip"`
IsSvip int `json:"is_svip"`
IsVip int `json:"is_vip"`
NameColor string `json:"name_color"`
} `json:"user_info"`
IsSendAudit int `json:"is_send_audit"`
Price int `json:"price"`
BackgroundColor string `json:"background_color"`
ColorPoint float64 `json:"color_point"`
Gift struct {
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
Num int `json:"num"`
} `json:"gift"`
MedalInfo struct {
TargetID int64 `json:"target_id"`
AnchorRoomid int `json:"anchor_roomid"`
AnchorUname string `json:"anchor_uname"`
GuardLevel int `json:"guard_level"`
MedalColor string `json:"medal_color"`
MedalColorEnd int `json:"medal_color_end"`
MedalLevel int `json:"medal_level"`
Special string `json:"special"`
IconID int64 `json:"icon_id"`
IsLighted int `json:"is_lighted"`
MedalColorBorder int `json:"medal_color_border"`
MedalColorStart int `json:"medal_color_start"`
MedalName string `json:"medal_name"`
} `json:"medal_info"`
TransMark int `json:"trans_mark"`
Ts int `json:"ts"`
BackgroundColorStart string `json:"background_color_start"`
EndTime int64 `json:"end_time"`
MessageFontColor string `json:"message_font_color"`
Rate int `json:"rate"`
MessageTrans string `json:"message_trans"`
StartTime int64 `json:"start_time"`
IsRanked int `json:"is_ranked"`
Message string `json:"message"`
Time int64 `json:"time"`
UID int64 `json:"uid"`
}
func (m *MsgSuperChatMessage) Parse() (*SuperChatMessage, error) {
var r = &SuperChatMessage{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgHotRankSettlement 荣登热门榜topX
type MsgHotRankSettlement struct {
base
}
func (m *MsgHotRankSettlement) Cmd() string {
return cmdHotRankSettlement
}
func (m *MsgHotRankSettlement) Raw() []byte {
return m.raw
}
type HotRankSettlement struct {
DmMsg string `json:"dm_msg"`
DmScore int `json:"dmscore"`
Timestamp int64 `json:"timestamp"`
Uname string `json:"uname"`
Url string `json:"url"`
AreaName string `json:"area_name"`
CacheKey string `json:"cache_key"`
Rank int `json:"rank"`
Face string `json:"face"`
Icon string `json:"icon"`
}
func (m *MsgHotRankSettlement) Parse() (*HotRankSettlement, error) {
var r = &HotRankSettlement{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgOnlineRankTop3 高能榜TOP3改变
type MsgOnlineRankTop3 struct {
base
}
func (m *MsgOnlineRankTop3) Cmd() string {
return cmdOnlineRankTop3
}
func (m *MsgOnlineRankTop3) Raw() []byte {
return m.raw
}
type OnlineRankTop3 struct {
DmScore int `json:"dmscore"`
List []struct {
Msg string `json:"msg"`
Rank int `json:"rank"`
} `json:"list"`
}
func (m *MsgOnlineRankTop3) Parse() (*OnlineRankTop3, error) {
var r = &OnlineRankTop3{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgRoomBlockMsg 用户被禁言
type MsgRoomBlockMsg struct {
base
}
func (m *MsgRoomBlockMsg) Cmd() string {
return cmdRoomBlockMsg
}
func (m *MsgRoomBlockMsg) Raw() []byte {
return m.raw
}
type RoomBlockMsg struct {
Uname string `json:"uname"`
DmScore int `json:"dmscore"`
Operator int `json:"operator"`
UID int `json:"uid"`
}
func (m *MsgRoomBlockMsg) Parse() (*RoomBlockMsg, error) {
var r = &RoomBlockMsg{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgStopLiveRoomList 刚刚停止了直播的直播间
type MsgStopLiveRoomList struct {
base
}
func (m *MsgStopLiveRoomList) Cmd() string {
return cmdStopLiveRoomList
}
func (m *MsgStopLiveRoomList) Raw() []byte {
return m.raw
}
// GetList 返回停播直播间号数组
func (m *MsgStopLiveRoomList) GetList() ([]int64, error) {
var r struct {
RoomIDList []int64 `json:"room_id_list"`
}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r.RoomIDList, nil
}
//
// MsgOnlineRankV2 高能榜数据
type MsgOnlineRankV2 struct {
base
}
func (m *MsgOnlineRankV2) Cmd() string {
return cmdOnlineRankV2
}
func (m *MsgOnlineRankV2) Raw() []byte {
return m.raw
}
type OnlineRankV2 struct {
List []struct {
GuardLevel int `json:"guard_level"` // 3:舰长 2:提督 1:总督?
UID int64 `json:"uid"`
Face string `json:"face"`
Score string `json:"score"`
Uname string `json:"uname"`
Rank int `json:"rank"`
} `json:"list"`
RankType string `json:"rank_type"`
}
func (m *MsgOnlineRankV2) Parse() (*OnlineRankV2, error) {
var r = &OnlineRankV2{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgNoticeMsg 广播消息(别的直播间投递高价礼物对所有直播间发起的广播)
type MsgNoticeMsg struct {
base
}
func (m *MsgNoticeMsg) Cmd() string {
return cmdNoticeMsg
}
func (m *MsgNoticeMsg) Raw() []byte {
return m.raw
}
type NoticeMsg struct {
BusinessID string `json:"business_id"`
Full struct {
HeadIcon string `json:"head_icon"`
TailIcon string `json:"tail_icon"`
HeadIconFa string `json:"head_icon_fa"`
TailIconFa string `json:"tail_icon_fa"`
Background string `json:"background"`
Highlight string `json:"highlight"`
HeadIconFan int `json:"head_icon_fan"`
TailIconFan int `json:"tail_icon_fan"`
Color string `json:"color"`
Time int64 `json:"time"`
} `json:"full"`
Half struct {
Time int64 `json:"time"`
HeadIcon string `json:"head_icon"`
TailIcon string `json:"tail_icon"`
Background string `json:"background"`
Color string `json:"color"`
Highlight string `json:"highlight"`
} `json:"half"`
ID int64 `json:"id"`
LinkUrl string `json:"link_url"`
MsgCommon string `json:"msg_common"`
MsgSelf string `json:"msg_self"`
MsgType int `json:"msg_type"`
Name string `json:"name"`
RealRoomID int64 `json:"real_roomid"`
RoomID int64 `json:"roomid"`
Scatter struct {
Min int `json:"min"`
Max int `json:"max"`
} `json:"scatter"`
ShieldUID int64 `json:"shield_uid"`
Side struct {
HeadIcon string `json:"head_icon"`
Background string `json:"background"`
Color string `json:"color"`
Highlight string `json:"highlight"`
Border string `json:"border"`
} `json:"side"`
}
func (m *MsgNoticeMsg) Parse() (*NoticeMsg, error) {
var r = &NoticeMsg{}
if err := json.Unmarshal(m.raw, &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgHotRankChanged 热门榜改变
type MsgHotRankChanged struct {
base
}
func (m *MsgHotRankChanged) Cmd() string {
return cmdHotRankChanged
}
func (m *MsgHotRankChanged) Raw() []byte {
return m.raw
}
type HotRankChanged struct {
Rank int `json:"rank"`
Timestamp int64 `json:"timestamp"`
WebUrl string `json:"web_url"`
LiveUrl string `json:"live_url"`
LiveLinkUrl string `json:"live_link_url"`
AreaName string `json:"area_name"`
Trend int `json:"trend"`
Countdown int `json:"countdown"`
BlinkUrl string `json:"blink_url"`
PCLinkUrl string `json:"pc_link_url"`
Icon string `json:"icon"`
}
func (m *MsgHotRankChanged) Parse() (*HotRankChanged, error) {
var r = &HotRankChanged{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgGuardBuy 用户上舰长
type MsgGuardBuy struct {
base
}
func (m *MsgGuardBuy) Cmd() string {
return cmdGuardBuy
}
func (m *MsgGuardBuy) Raw() []byte {
return m.raw
}
type GuardBuy struct {
GuardLevel int `json:"guard_level"`
Price int `json:"price"`
UID int64 `json:"uid"`
Num int `json:"num"`
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Username string `json:"username"`
}
func (m *MsgGuardBuy) Parse() (*GuardBuy, error) {
var r = &GuardBuy{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgSuperChatMessageJPN 醒目留言日文翻译?
type MsgSuperChatMessageJPN struct {
base
}
func (m *MsgSuperChatMessageJPN) Cmd() string {
return cmdSuperChatMessageJPN
}
func (m *MsgSuperChatMessageJPN) Raw() []byte {
return m.raw
}
type SuperChatMessageJPN struct {
UID string `json:"uid"`
IsRanked int `json:"is_ranked"`
MedalInfo struct {
MedalColor string `json:"medal_color"`
IconID int64 `json:"icon_id"`
TargetID int64 `json:"target_id"`
Special string `json:"special"`
AnchorUname string `json:"anchor_uname"`
AnchorRoomid int `json:"anchor_roomid"`
MedalLevel int `json:"medal_level"`
MedalName string `json:"medal_name"`
} `json:"medal_info"`
UserInfo struct {
UserLevel int `json:"user_level"`
LevelColor string `json:"level_color"`
IsVip int `json:"is_vip"`
IsSvip int `json:"is_svip"`
IsMainVip int `json:"is_main_vip"`
Title string `json:"title"`
Uname string `json:"uname"`
Face string `json:"face"`
Manager int `json:"manager"`
FaceFrame string `json:"face_frame"`
GuardLevel int `json:"guard_level"`
} `json:"user_info"`
ID string `json:"id"`
MessageJpn string `json:"message_jpn"`
Time int64 `json:"time"`
Rate int `json:"rate"`
BackgroundImage string `json:"background_image"`
BackgroundIcon string `json:"background_icon"`
BackgroundPriceColor string `json:"background_price_color"`
Token string `json:"token"`
Gift struct {
Num int `json:"num"`
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
} `json:"gift"`
Price int `json:"price"`
Message string `json:"message"`
BackgroundColor string `json:"background_color"`
BackgroundBottomColor string `json:"background_bottom_color"`
TS int64 `json:"ts"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
}
func (m *MsgSuperChatMessageJPN) Parse() (*SuperChatMessageJPN, error) {
var r = &SuperChatMessageJPN{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgUserToastMsg 上船附带的通知
type MsgUserToastMsg struct {
base
}
func (m *MsgUserToastMsg) Cmd() string {
return cmdUserToastMsg
}
func (m *MsgUserToastMsg) Raw() []byte {
return m.raw
}
type UserToastMsg struct {
GuardLevel int `json:"guard_level"`
OpType int `json:"op_type"`
PayflowID string `json:"payflow_id"`
Unit string `json:"unit"`
IsShow int `json:"is_show"`
Num int `json:"num"`
Price int64 `json:"price"`
StartTime int64 `json:"start_time"`
SvgaBlock int `json:"svga_block"`
UserShow bool `json:"user_show"`
Color string `json:"color"`
EndTime int64 `json:"end_time"`
RoleName string `json:"role_name"`
ToastMsg string `json:"toast_msg"`
UID int64 `json:"uid"`
AnchorShow bool `json:"anchor_show"`
DmScore int `json:"dmscore"`
TargetGuardCount int `json:"target_guard_count"`
Username string `json:"username"`
}
func (m *MsgUserToastMsg) Parse() (*UserToastMsg, error) {
var r = &UserToastMsg{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgSuperChatMessageDelete 删除醒目留言 (似乎有时候并不会发,同时结束时间在 CmdSuperChatMessage 可以获取)
type MsgSuperChatMessageDelete struct {
base
}
func (m *MsgSuperChatMessageDelete) Cmd() string {
return cmdSuperChatMessageDelete
}
func (m *MsgSuperChatMessageDelete) Raw() []byte {
return m.raw
}
// GetList 返回id数组
func (m *MsgSuperChatMessageDelete) GetList() ([]int64, error) {
var r struct {
IDS []int64 `json:"ids"`
}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r.IDS, nil
}
//
// MsgAnchorLotStart 天选之人开始完整信息
type MsgAnchorLotStart struct {
base
}
func (m *MsgAnchorLotStart) Cmd() string {
return cmdAnchorLotStart
}
func (m *MsgAnchorLotStart) Raw() []byte {
return m.raw
}
type AnchorLotStart struct {
MaxTime int `json:"max_time"`
Danmu string `json:"danmu"`
GiftNum int `json:"gift_num"`
JoinType int `json:"join_type"`
AwardImage string `json:"award_image"`
GiftPrice int `json:"gift_price"`
GiftID int64 `json:"gift_id"`
GiftName string `json:"gift_name"`
GoodsID int64 `json:"goods_id"`
RoomID int64 `json:"room_id"`
Time int64 `json:"time"`
Url string `json:"url"`
CurGiftNum int `json:"cur_gift_num"`
CurrentTime int64 `json:"current_time"`
LotStatus int `json:"lot_status"`
RequireType int `json:"require_type"`
WebUrl string `json:"web_url"`
GoawayTime int `json:"goaway_time"`
IsBroadcast int `json:"is_broadcast"`
RequireValue int `json:"require_value"`
ShowPanel int `json:"show_panel"`
Status int `json:"status"`
ID int64 `json:"id"`
RequireText string `json:"require_text"`
AwardNum int `json:"award_num"`
AssetIcon string `json:"asset_icon"`
AwardName string `json:"award_name"`
SendGiftEnsure int `json:"send_gift_ensure"`
}
func (m *MsgAnchorLotStart) Parse() (*AnchorLotStart, error) {
var r = &AnchorLotStart{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgAnchorLotCheckStatus 天选时刻前的审核
type MsgAnchorLotCheckStatus struct {
base
}
func (m *MsgAnchorLotCheckStatus) Cmd() string {
return cmdAnchorLotCheckStatus
}
func (m *MsgAnchorLotCheckStatus) Raw() []byte {
return m.raw
}
/*
{
"id": 1890708,
"reject_reason": "",
"status": 4,
"uid": 2920960
}
*/
type AnchorLotCheckStatus struct {
ID int64 `json:"id"`
RejectReason string `json:"reject_reason"`
Status int `json:"status"`
Uid int64 `json:"uid"`
}
func (m *MsgAnchorLotCheckStatus) Parse() (*AnchorLotCheckStatus, error) {
var r = &AnchorLotCheckStatus{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
//
// MsgAnchorLotAward 天选结果推送
type MsgAnchorLotAward struct {
base
}
func (m *MsgAnchorLotAward) Cmd() string {
return cmdAnchorLotAward
}
func (m *MsgAnchorLotAward) Raw() []byte {
return m.raw
}
type AnchorLotAward struct {
LotStatus int `json:"lot_status"`
Url string `json:"url"`
WebUrl string `json:"web_url"`
AwardImage string `json:"award_image"`
AwardName string `json:"award_name"`
AwardNum int `json:"award_num"`
AwardUsers []struct {
Uname string `json:"uname"`
Face string `json:"face"`
Level int `json:"level"`
Color int64 `json:"color"`
UID int64 `json:"uid"`
} `json:"award_users"`
ID int64 `json:"id"`
}
func (m *MsgAnchorLotAward) Parse() (*AnchorLotAward, error) {
var r = &AnchorLotAward{}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return nil, err
}
return r, nil
}
// MsgAnchorLotEnd 天选之人获奖id
type MsgAnchorLotEnd struct {
base
}
func (m *MsgAnchorLotEnd) Cmd() string {
return cmdAnchorLotEnd
}
func (m *MsgAnchorLotEnd) Raw() []byte {
return m.raw
}
func (m *MsgAnchorLotEnd) GetID() int64 {
var r struct {
ID int64 `json:"id"`
}
if err := json.Unmarshal(getData(m.raw), &r); err != nil {
return -1
}
return r.ID
}
//