From 574e588904d3c8b28e682ba441e3a6b7af28a4d3 Mon Sep 17 00:00:00 2001 From: qydysky <32743305+qydysky@users.noreply.github.com> Date: Sat, 24 Sep 2022 01:10:44 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E4=BF=9D=E6=8C=81=E4=BA=AE?= =?utf8?q?=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index 70d9ad7..b761c9a 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -24,6 +24,7 @@ import ( c "github.com/qydysky/bili_danmu/CV" F "github.com/qydysky/bili_danmu/F" + J "github.com/qydysky/bili_danmu/Json" send "github.com/qydysky/bili_danmu/Send" p "github.com/qydysky/part" @@ -949,48 +950,57 @@ func Keep_medal_light() { } flog.L(`T: `, `开始`) + defer flog.L(`I: `, `完成`) - var hasKeep bool - for _, v := range F.Get_list_in_room() { + cacheInfo := make(map[int]J.Info) + medals := F.Get_list_in_room() + if len(medals) == 0 { + return + } + for _, v := range medals { if v.IsLighted == 1 { continue } //点亮状态 - hasKeep = true - - info := F.Info(v.TargetID) + cacheInfo[v.TargetID] = F.Info(v.TargetID) //两天内到期,发弹幕续期 rand := p.Rand().MixRandom(0, int64(len(array)-1)) - send.Danmu_s(array[rand].(string), info.Data.LiveRoom.Roomid) + send.Danmu_s(array[rand].(string), cacheInfo[v.TargetID].Data.LiveRoom.Roomid) time.Sleep(time.Second) } //重试,使用点赞 - for _, v := range F.Get_list_in_room() { + medals = F.Get_list_in_room() + if len(medals) == 0 { + return + } + for _, v := range medals { if v.IsLighted == 1 { continue } - info := F.Info(v.TargetID) //两天内到期,发弹幕续期 send.Danmu_s2(map[string]string{ `msg`: `official_147`, `dm_type`: `1`, - `roomid`: strconv.Itoa(info.Data.LiveRoom.Roomid), + `roomid`: strconv.Itoa(cacheInfo[v.TargetID].Data.LiveRoom.Roomid), }) time.Sleep(time.Second) } //重试,使用历史弹幕 - for _, v := range F.Get_list_in_room() { + medals = F.Get_list_in_room() + if len(medals) == 0 { + return + } + for _, v := range medals { if v.IsLighted == 1 { continue } - info := F.Info(v.TargetID) //两天内到期,发弹幕续期 var Str string - for _, v := range F.GetHistory(info.Data.LiveRoom.Roomid).Data.Room { + for _, v := range F.GetHistory(cacheInfo[v.TargetID].Data.LiveRoom.Roomid).Data.Room { if v.Text != "" { Str = v.Text break @@ -1000,15 +1010,9 @@ func Keep_medal_light() { rand := p.Rand().MixRandom(0, int64(len(array)-1)) Str = array[rand].(string) } - send.Danmu_s(Str, info.Data.LiveRoom.Roomid) + send.Danmu_s(Str, cacheInfo[v.TargetID].Data.LiveRoom.Roomid) time.Sleep(time.Second) } - - if hasKeep { - flog.L(`I: `, `完成`) - } else { - flog.L(`T: `, `完成`) - } } // 自动发送即将过期的银瓜子礼物 -- 2.39.2