@@ -26,15 +26,15 @@ import (
26
26
)
27
27
28
28
const (
29
- ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
30
- referer = "https://www.bilibili.com/"
31
- infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%d"
32
- userDynamicsURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%d&offset_dynamic_id=0&need_top=0"
33
- liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
34
- tURL = "https://t.bilibili.com/"
35
- liveURL = "https://live.bilibili.com/"
36
- prio = 10
37
- serviceName = "bilibilipush"
29
+ ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
30
+ referer = "https://www.bilibili.com/"
31
+ infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%d"
32
+ userDynamicURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%d&offset_dynamic_id=0&need_top=0"
33
+ liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
34
+ tURL = "https://t.bilibili.com/"
35
+ liveURL = "https://live.bilibili.com/"
36
+ prio = 10
37
+ serviceName = "bilibilipush"
38
38
)
39
39
40
40
var (
@@ -281,7 +281,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
281
281
}
282
282
283
283
func getUserDynamicCard (buid int64 ) (cardList []gjson.Result ) {
284
- data , err := web .ReqWith (fmt .Sprintf (userDynamicsURL , buid ), "GET" , referer , ua )
284
+ data , err := web .ReqWith (fmt .Sprintf (userDynamicURL , buid ), "GET" , referer , ua )
285
285
if err != nil {
286
286
log .Errorln ("[bilibilipush]:" , err )
287
287
}
@@ -345,11 +345,12 @@ func sendDynamic() {
345
345
zero .RangeBot (func (id int64 , ctx * zero.Ctx ) bool {
346
346
for _ , gid := range groupList {
347
347
if m .IsEnabledIn (gid ) {
348
- if gid > 0 {
348
+ switch {
349
+ case gid > 0 :
349
350
ctx .SendGroupMessage (gid , msg )
350
- } else if gid < 0 {
351
+ case gid < 0 :
351
352
ctx .SendPrivateMessage (- gid , msg )
352
- } else {
353
+ default :
353
354
log .Errorln ("[bilibilipush]:gid为0" )
354
355
}
355
356
}
@@ -398,18 +399,21 @@ func sendLive() {
398
399
zero .RangeBot (func (id int64 , ctx * zero.Ctx ) bool {
399
400
for _ , gid := range groupList {
400
401
if m .IsEnabledIn (gid ) {
401
- if gid > 0 {
402
+ switch {
403
+ case gid > 0 :
402
404
ctx .SendGroupMessage (gid , msg )
403
- } else if gid < 0 {
405
+ case gid < 0 :
404
406
ctx .SendPrivateMessage (- gid , msg )
405
- } else {
407
+ default :
406
408
log .Errorln ("[bilibilipush]:gid为0" )
407
409
}
408
410
}
409
411
}
410
412
return true
411
413
})
412
414
}
415
+ } else if newStatus != oldStatus {
416
+ liveStatus [key .Int ()] = newStatus
413
417
}
414
418
return true
415
419
})
0 commit comments