From 436d4cedaa56a831c290ebab4a996d1096114adb Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Mon, 6 Mar 2023 22:54:36 +0800 Subject: [PATCH] =?utf8?q?Fix=20ws=E6=B6=88=E6=81=AF=20=E4=BF=AE=E5=A4=8DS?= =?utf8?q?C=20SUPER=5FCHAT=5FMESSAGE=5FJPN=20=E5=BC=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/Msg.go | 4 +- Reply/Reply.go | 26 +++++------- Reply/ws_msg/SUPER_CHAT_MESSAGE.go | 66 ++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 Reply/ws_msg/SUPER_CHAT_MESSAGE.go diff --git a/Reply/Msg.go b/Reply/Msg.go index a826a68..7fb4c0b 100644 --- a/Reply/Msg.go +++ b/Reply/Msg.go @@ -86,8 +86,8 @@ var Msg_map = map[string]func(replyF, string){ "LIVE": replyF.live, //开播 "SUPER_CHAT_ENTRANCE": nil, //SC入口 "SUPER_CHAT_MESSAGE_DELETE": nil, //SC删除 - "SUPER_CHAT_MESSAGE": nil, //replyF.super_chat_message,//SC - "SUPER_CHAT_MESSAGE_JPN": replyF.super_chat_message, //SC + "SUPER_CHAT_MESSAGE": replyF.super_chat_message, //SC + "SUPER_CHAT_MESSAGE_JPN": nil, //replyF.super_chat_message, //SC "PANEL": nil, //replyF.panel,//排行榜 被HOT_RANK_CHANGED替代 "ENTRY_EFFECT": replyF.entry_effect, //进入特效 "ROOM_REAL_TIME_MESSAGE_UPDATE": nil, //replyF.roominfo,//粉丝数 diff --git a/Reply/Reply.go b/Reply/Reply.go index 8a3aaf0..a384c2b 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -795,18 +795,18 @@ func (replyF) live(s string) { } // Msg-超级留言处理 -var sc_buf = make(map[string]struct{}) +var sc_buf = make(map[int]struct{}) func (replyF) super_chat_message(s string) { msglog := msglog.Base_add("礼") - var j ws_msg.SUPER_CHAT_MESSAGE_JPN + var j ws_msg.SUPER_CHAT_MESSAGE if e := json.Unmarshal([]byte(s), &j); e != nil { msglog.L(`E: `, e) } id := j.Data.ID - if id != "" { + if id != 0 { if _, ok := sc_buf[id]; ok { return } @@ -816,7 +816,7 @@ func (replyF) super_chat_message(s string) { break } { //copy map - tmp := make(map[string]struct{}) + tmp := make(map[int]struct{}) for k, v := range sc_buf { tmp[k] = v } @@ -828,7 +828,6 @@ func (replyF) super_chat_message(s string) { uname := j.Data.UserInfo.Uname price := j.Data.Price message := j.Data.Message - message_jpn := j.Data.MessageJpn var sh = []interface{}{"SC: "} @@ -852,24 +851,21 @@ func (replyF) super_chat_message(s string) { c.C.Danmu_Main_mq.Push_tag(`tts`, Danmu_mq_t{ //传入消息队列 uid: `0superchat`, m: map[string]string{ - `{uname}`: uname, - `{price}`: strconv.Itoa(price), - `{message}`: message, - `{message_jpn}`: message_jpn, + `{uname}`: uname, + `{price}`: strconv.Itoa(price), + `{message}`: message, }, }) } - if message != message_jpn && message_jpn != "" { - fmt.Println(message_jpn) - // Gui_show(message_jpn.(string)) - sh = append(sh, message_jpn) - logg = append(logg, message_jpn) + if message != "" { + fmt.Println(message) + sh = append(sh, message) + logg = append(logg, message) } fmt.Print("====\n") { //额外 Assf(fmt.Sprintln(sh...)) - // Gui_show("====\n") Gui_show(Itos(sh), "0superchat") //直播流服务弹幕 SendStreamWs(Danmu_item{ diff --git a/Reply/ws_msg/SUPER_CHAT_MESSAGE.go b/Reply/ws_msg/SUPER_CHAT_MESSAGE.go new file mode 100644 index 0000000..928dcaf --- /dev/null +++ b/Reply/ws_msg/SUPER_CHAT_MESSAGE.go @@ -0,0 +1,66 @@ +package part + +type SUPER_CHAT_MESSAGE struct { + Cmd string `json:"cmd"` + Data struct { + BackgroundBottomColor string `json:"background_bottom_color"` + BackgroundColor string `json:"background_color"` + BackgroundColorEnd string `json:"background_color_end"` + BackgroundColorStart string `json:"background_color_start"` + BackgroundIcon string `json:"background_icon"` + BackgroundImage string `json:"background_image"` + BackgroundPriceColor string `json:"background_price_color"` + ColorPoint float64 `json:"color_point"` + Dmscore int `json:"dmscore"` + EndTime int `json:"end_time"` + Gift struct { + GiftID int `json:"gift_id"` + GiftName string `json:"gift_name"` + Num int `json:"num"` + } `json:"gift"` + ID int `json:"id"` + IsRanked int `json:"is_ranked"` + IsSendAudit int `json:"is_send_audit"` + MedalInfo struct { + AnchorRoomid int `json:"anchor_roomid"` + AnchorUname string `json:"anchor_uname"` + GuardLevel int `json:"guard_level"` + IconID int `json:"icon_id"` + IsLighted int `json:"is_lighted"` + MedalColor string `json:"medal_color"` + MedalColorBorder int `json:"medal_color_border"` + MedalColorEnd int `json:"medal_color_end"` + MedalColorStart int `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"` + Message string `json:"message"` + MessageFontColor string `json:"message_font_color"` + MessageTrans string `json:"message_trans"` + Price int `json:"price"` + Rate int `json:"rate"` + StartTime int `json:"start_time"` + Time int `json:"time"` + Token string `json:"token"` + TransMark int `json:"trans_mark"` + Ts int `json:"ts"` + UID int `json:"uid"` + UserInfo struct { + Face string `json:"face"` + FaceFrame string `json:"face_frame"` + GuardLevel int `json:"guard_level"` + IsMainVip int `json:"is_main_vip"` + IsSvip int `json:"is_svip"` + IsVip int `json:"is_vip"` + LevelColor string `json:"level_color"` + Manager int `json:"manager"` + NameColor string `json:"name_color"` + Title string `json:"title"` + Uname string `json:"uname"` + UserLevel int `json:"user_level"` + } `json:"user_info"` + } `json:"data"` + Roomid int `json:"roomid"` +} -- 2.39.2