Skip to content
This repository has been archived by the owner on Jun 22, 2023. It is now read-only.

Commit

Permalink
fix Bili订阅订阅者ID不存在时的回复
Browse files Browse the repository at this point in the history
  • Loading branch information
mcoo committed Jun 1, 2021
1 parent 23eaaff commit a019e79
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,40 @@ func main() {
c.AddJob(-1, "Bili", "*/5 * * * *", func() {
update, fanju := bi.ScanUpdate()
for _, v := range update {
upName, gs ,userId := bi.GetUpGroupsByMid(v.Mid)
upName, gs, userId := bi.GetUpGroupsByMid(v.Mid)
for _, g := range gs {
if v1, ok := Config.CoreConfig.GroupConfig[g]; ok {
if !v1.Bili {
break
}
}
res, _ := requests.Get(v.Pic)
b.Send(OPQBot.SendMsgPack{
SendToType: OPQBot.SendToTypeGroup,
ToUserUid: g,
Content: OPQBot.SendTypePicMsgByBase64Content{
Content: OPQBot.MacroAt([]int64{userId}) + fmt.Sprintf("您订阅的UP主%s更新了\n%s\n%s", upName, v.Title, v.Description),
Base64: base64.StdEncoding.EncodeToString(res.Content()),
Flash: false,
},
})
if userId != 0 {
b.Send(OPQBot.SendMsgPack{
SendToType: OPQBot.SendToTypeGroup,
ToUserUid: g,
Content: OPQBot.SendTypePicMsgByBase64Content{
Content: OPQBot.MacroAt([]int64{userId}) + fmt.Sprintf("您订阅的UP主%s更新了\n%s\n%s", upName, v.Title, v.Description),
Base64: base64.StdEncoding.EncodeToString(res.Content()),
Flash: false,
},
})
} else {
b.Send(OPQBot.SendMsgPack{
SendToType: OPQBot.SendToTypeGroup,
ToUserUid: g,
Content: OPQBot.SendTypePicMsgByBase64Content{
Content: fmt.Sprintf("不知道是谁订阅的UP主%s更新了\n%s\n%s", upName, v.Title, v.Description),
Base64: base64.StdEncoding.EncodeToString(res.Content()),
Flash: false,
},
})
}

}
}
for _, v := range fanju {
title, gs ,userId:= bi.GetFanjuGroupsByMid(v.Result.Media.MediaID)
title, gs, userId := bi.GetFanjuGroupsByMid(v.Result.Media.MediaID)
for _, g := range gs {
if v1, ok := Config.CoreConfig.GroupConfig[g]; ok {
if !v1.Bili {
Expand Down Expand Up @@ -356,7 +369,7 @@ func main() {
}
if v1, ok := v.(map[int]int64); ok {
if v2, ok := v1[id]; ok {
u, err := bi.SubscribeUpByMid(packet.FromGroupID, v2 ,packet.FromUserID)
u, err := bi.SubscribeUpByMid(packet.FromGroupID, v2, packet.FromUserID)
if err != nil {
b.SendGroupTextMsg(packet.FromGroupID, err.Error())
err = s.Delete("biliUps")
Expand Down Expand Up @@ -461,7 +474,7 @@ func main() {
b.SendGroupTextMsg(packet.FromGroupID, fmt.Sprintf("====输入序号选择UP====\n%s", strings.Join(resultStr, "\n")))
return
}
u, err := bi.SubscribeUpByMid(packet.FromGroupID, mid , packet.FromUserID)
u, err := bi.SubscribeUpByMid(packet.FromGroupID, mid, packet.FromUserID)
if err != nil {
b.SendGroupTextMsg(packet.FromGroupID, err.Error())
return
Expand Down Expand Up @@ -495,7 +508,7 @@ func main() {
b.SendGroupTextMsg(packet.FromGroupID, "本群没有订阅UP主")
return
}
for mid, v1 := range c.BiliUps {
for mid, v1 := range c.BiliUps {
ups += fmt.Sprintf("%d - %s - 订阅者 - %d\n", mid, v1.Name, v1.UserId)
}
b.SendGroupTextMsg(packet.FromGroupID, ups)
Expand All @@ -507,7 +520,7 @@ func main() {
}
mid, err := strconv.ParseInt(cm[1], 10, 64)
if err != nil {
u, err := bi.SubscribeFanjuByKeyword(packet.FromGroupID, cm[1],packet.FromUserID)
u, err := bi.SubscribeFanjuByKeyword(packet.FromGroupID, cm[1], packet.FromUserID)
if err != nil {
b.SendGroupTextMsg(packet.FromGroupID, err.Error())
return
Expand All @@ -516,7 +529,7 @@ func main() {
b.SendGroupPicMsg(packet.FromGroupID, "成功订阅番剧"+u.Result.Media.Title, r.Content())
return
}
u, err := bi.SubscribeFanjuByMid(packet.FromGroupID, mid,packet.FromUserID)
u, err := bi.SubscribeFanjuByMid(packet.FromGroupID, mid, packet.FromUserID)
if err != nil {
b.SendGroupTextMsg(packet.FromGroupID, err.Error())
return
Expand Down Expand Up @@ -551,7 +564,7 @@ func main() {
return
}
for mid, v1 := range c.Fanjus {
ups += fmt.Sprintf("%d - %s-订阅用户为:%d\n", mid, v1.Title,v1.UserId)
ups += fmt.Sprintf("%d - %s-订阅用户为:%d\n", mid, v1.Title, v1.UserId)
}
b.SendGroupTextMsg(packet.FromGroupID, ups)

Expand Down

0 comments on commit a019e79

Please sign in to comment.