From 5de4847e3b40f4ec875cdbfc514421a07c84760b Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 5 Apr 2022 18:41:36 +0800 Subject: [PATCH] =?utf8?q?=E8=8E=B7=E5=8F=96=E7=89=8C=E5=AD=90=E5=88=97?= =?utf8?q?=E8=A1=A8fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- F/api.go | 37 ++++++++-------------- Json/getWearedMedal.go | 70 ++++++++++++++++++++++++++++++++++++++++++ Reply/F.go | 2 +- 3 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 Json/getWearedMedal.go diff --git a/F/api.go b/F/api.go index f2d446b..6b2f856 100644 --- a/F/api.go +++ b/F/api.go @@ -1421,7 +1421,7 @@ func Get_list_in_room() (array []J.GetMyMedals_Items) { for pageNum := 1; true; pageNum += 1 { r := reqf.New() if e := r.Reqf(reqf.Rval{ - Url: `https://api.live.bilibili.com/xlive/app-ucenter/v1/user/GetMyMedals?page=` + strconv.Itoa(pageNum) + `&pageSize=10`, + Url: `https://api.live.bilibili.com/xlive/app-ucenter/v1/user/GetMyMedals?page=` + strconv.Itoa(pageNum) + `&page_size=10`, Header: map[string]string{ `Cookie`: reqf.Map_2_Cookies_String(Cookie), }, @@ -1457,21 +1457,8 @@ func Get_list_in_room() (array []J.GetMyMedals_Items) { } } -type TGet_weared_medal struct { - Medal_id int `json:"medal_id"` //牌子id - Medal_name string `json:"medal_name"` //牌子名 - Target_id int `json:"target_id"` //牌子up主uid - Target_name string `json:"target_name"` //牌子up主名 - Roominfo Roominfo `json:"roominfo"` //牌子直播间 - Today_intimacy int `json:"today_intimacy"` //今日亲密(0:未发送弹幕 100:已发送弹幕) - Is_lighted int `json:"is_lighted"` //牌子是否熄灭(0:熄灭 1:亮) -} -type Roominfo struct { - Room_id int `json:"room_id"` -} - //获取当前佩戴的牌子 -func Get_weared_medal() (item TGet_weared_medal) { +func Get_weared_medal() (item J.GetWearedMedal_Data) { apilog := apilog.Base_add(`获取牌子`) //验证cookie @@ -1504,13 +1491,8 @@ func Get_weared_medal() (item TGet_weared_medal) { return } - var res struct { - Code int `json:"code"` - Msg string `json:"msg"` - Message string `json:"message"` - Data TGet_weared_medal `json:"data"` - } - if e := json.Unmarshal(r.Respon, &res); e != nil && res.Msg == `` { //未佩戴时的data是array型会导致错误 + var res J.GetWearedMedal + if e := json.Unmarshal(r.Respon, &res); e != nil { apilog.L(`E: `, e) return } @@ -1520,7 +1502,12 @@ func Get_weared_medal() (item TGet_weared_medal) { return } - return res.Data + switch res.Data.(type) { + case J.GetWearedMedal_Data: + return res.Data.(J.GetWearedMedal_Data) + default: + } + return } } @@ -1556,8 +1543,8 @@ func CheckSwitch_FansMedal() (missKey []string) { { //获取当前牌子,验证是否本直播间牌子 res := Get_weared_medal() - c.Wearing_FansMedal = res.Roominfo.Room_id //更新佩戴信息 - if res.Target_id == c.UpUid { + c.Wearing_FansMedal = res.Roominfo.RoomID //更新佩戴信息 + if res.TargetID == c.UpUid { return } } diff --git a/Json/getWearedMedal.go b/Json/getWearedMedal.go new file mode 100644 index 0000000..907b6a5 --- /dev/null +++ b/Json/getWearedMedal.go @@ -0,0 +1,70 @@ +package part + +type GetWearedMedal struct { + Code int `json:"code"` + Msg string `json:"msg"` + Message string `json:"message"` + Data interface{} `json:"data"` +} +type GetWearedMedal_Roominfo struct { + Title string `json:"title"` + RoomID int `json:"room_id"` + UID int `json:"uid"` + Online int `json:"online"` + LiveTime int `json:"live_time"` + LiveStatus int `json:"live_status"` + ShortID int `json:"short_id"` + Area int `json:"area"` + AreaName string `json:"area_name"` + AreaV2ID int `json:"area_v2_id"` + AreaV2Name string `json:"area_v2_name"` + AreaV2ParentName string `json:"area_v2_parent_name"` + AreaV2ParentID int `json:"area_v2_parent_id"` + Uname string `json:"uname"` + Face string `json:"face"` + TagName string `json:"tag_name"` + Tags string `json:"tags"` + CoverFromUser string `json:"cover_from_user"` + Keyframe string `json:"keyframe"` + LockTill string `json:"lock_till"` + HiddenTill string `json:"hidden_till"` + BroadcastType int `json:"broadcast_type"` +} +type GetWearedMedal_Data struct { + GuardType int `json:"guard_type"` + Intimacy int `json:"intimacy"` + IsReceive int `json:"is_receive"` + LastWearTime int `json:"last_wear_time"` + Level int `json:"level"` + LplStatus int `json:"lpl_status"` + MasterAvailable int `json:"master_available"` + MasterStatus int `json:"master_status"` + MedalID int `json:"medal_id"` + MedalName string `json:"medal_name"` + ReceiveChannel int `json:"receive_channel"` + ReceiveTime string `json:"receive_time"` + Score int `json:"score"` + Source int `json:"source"` + Status int `json:"status"` + TargetID int `json:"target_id"` + TodayIntimacy int `json:"today_intimacy"` + UID int `json:"uid"` + TargetName string `json:"target_name"` + TargetFace string `json:"target_face"` + LiveStreamStatus int `json:"live_stream_status"` + IconCode int `json:"icon_code"` + IconText string `json:"icon_text"` + Rank string `json:"rank"` + MedalColor int `json:"medal_color"` + MedalColorStart int `json:"medal_color_start"` + MedalColorEnd int `json:"medal_color_end"` + GuardLevel int `json:"guard_level"` + MedalColorBorder int `json:"medal_color_border"` + IsLighted int `json:"is_lighted"` + TodayFeed int `json:"today_feed"` + DayLimit int `json:"day_limit"` + NextIntimacy int `json:"next_intimacy"` + CanDelete bool `json:"can_delete"` + IsUnion int `json:"is_union"` + Roominfo GetWearedMedal_Roominfo `json:"roominfo"` +} diff --git a/Reply/F.go b/Reply/F.go index c3da740..9afce20 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -2047,7 +2047,7 @@ func Entry_danmu() { } if v, _ := c.K_v.LoadV(`进房弹幕_仅发首日弹幕`).(bool); v { res := F.Get_weared_medal() - if res.Today_intimacy > 0 { + if res.TodayIntimacy > 0 { flog.L(`T: `, `今日已发弹幕`) return } -- 2.39.2