mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 14:30:10 +08:00
fix:修复直播状态更新的bug (#107)
* feat:添加b站推送,写了一半 * feat:添加b站推送(后续看情况,替换掉chromepd) * fix:修复一直推送直播的bug * fix:添加缓存路径 * feat:添加推送列表,修复重复发消息的bug * feat:发现禁用有用,删除多余指令 * fix:修改格式 * fix:sleep无效 * fix:修改直播card * fix:增加长度 * fix:修改readme * fix:修lint,并去掉cron * fix:修lint * fix:去掉日志 * fix:更新旧状态 * fix:删掉多余方法 * fix:优化判断语句 * fix:修lint Co-authored-by: Guohuiyuan <haibaraguo@yeahka.com>
This commit is contained in:
parent
9bd0ed03a5
commit
f8df60f06b
@ -26,15 +26,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
|
ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"
|
||||||
referer = "https://www.bilibili.com/"
|
referer = "https://www.bilibili.com/"
|
||||||
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%d"
|
infoURL = "https://api.bilibili.com/x/space/acc/info?mid=%d"
|
||||||
userDynamicsURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%d&offset_dynamic_id=0&need_top=0"
|
userDynamicURL = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?host_uid=%d&offset_dynamic_id=0&need_top=0"
|
||||||
liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
|
liveListURL = "https://api.live.bilibili.com/room/v1/Room/get_status_info_by_uids"
|
||||||
tURL = "https://t.bilibili.com/"
|
tURL = "https://t.bilibili.com/"
|
||||||
liveURL = "https://live.bilibili.com/"
|
liveURL = "https://live.bilibili.com/"
|
||||||
prio = 10
|
prio = 10
|
||||||
serviceName = "bilibilipush"
|
serviceName = "bilibilipush"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -281,7 +281,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
|
func getUserDynamicCard(buid int64) (cardList []gjson.Result) {
|
||||||
data, err := web.ReqWith(fmt.Sprintf(userDynamicsURL, buid), "GET", referer, ua)
|
data, err := web.ReqWith(fmt.Sprintf(userDynamicURL, buid), "GET", referer, ua)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln("[bilibilipush]:", err)
|
log.Errorln("[bilibilipush]:", err)
|
||||||
}
|
}
|
||||||
@ -345,11 +345,12 @@ func sendDynamic() {
|
|||||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
||||||
for _, gid := range groupList {
|
for _, gid := range groupList {
|
||||||
if m.IsEnabledIn(gid) {
|
if m.IsEnabledIn(gid) {
|
||||||
if gid > 0 {
|
switch {
|
||||||
|
case gid > 0:
|
||||||
ctx.SendGroupMessage(gid, msg)
|
ctx.SendGroupMessage(gid, msg)
|
||||||
} else if gid < 0 {
|
case gid < 0:
|
||||||
ctx.SendPrivateMessage(-gid, msg)
|
ctx.SendPrivateMessage(-gid, msg)
|
||||||
} else {
|
default:
|
||||||
log.Errorln("[bilibilipush]:gid为0")
|
log.Errorln("[bilibilipush]:gid为0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,11 +399,12 @@ func sendLive() {
|
|||||||
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
|
||||||
for _, gid := range groupList {
|
for _, gid := range groupList {
|
||||||
if m.IsEnabledIn(gid) {
|
if m.IsEnabledIn(gid) {
|
||||||
if gid > 0 {
|
switch {
|
||||||
|
case gid > 0:
|
||||||
ctx.SendGroupMessage(gid, msg)
|
ctx.SendGroupMessage(gid, msg)
|
||||||
} else if gid < 0 {
|
case gid < 0:
|
||||||
ctx.SendPrivateMessage(-gid, msg)
|
ctx.SendPrivateMessage(-gid, msg)
|
||||||
} else {
|
default:
|
||||||
log.Errorln("[bilibilipush]:gid为0")
|
log.Errorln("[bilibilipush]:gid为0")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,6 +412,8 @@ func sendLive() {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else if newStatus != oldStatus {
|
||||||
|
liveStatus[key.Int()] = newStatus
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|||||||
@ -53,21 +53,6 @@ func initialize(dbpath string) *bilibilipushdb {
|
|||||||
return (*bilibilipushdb)(gdb)
|
return (*bilibilipushdb)(gdb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// open ...
|
|
||||||
func open(dbpath string) (*bilibilipushdb, error) {
|
|
||||||
db, err := gorm.Open("sqlite3", dbpath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return (*bilibilipushdb)(db), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// close ...
|
|
||||||
func (bdb *bilibilipushdb) close() error {
|
|
||||||
db := (*gorm.DB)(bdb)
|
|
||||||
return db.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
// insertOrUpdateLiveAndDynamic 插入或更新数据库
|
// insertOrUpdateLiveAndDynamic 插入或更新数据库
|
||||||
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interface{}) (err error) {
|
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interface{}) (err error) {
|
||||||
db := (*gorm.DB)(bdb)
|
db := (*gorm.DB)(bdb)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user