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:
himawari 2022-01-15 11:01:33 +08:00 committed by GitHub
parent 9bd0ed03a5
commit f8df60f06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 31 deletions

View File

@ -29,7 +29,7 @@ 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"
referer = "https://www.bilibili.com/"
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"
tURL = "https://t.bilibili.com/"
liveURL = "https://live.bilibili.com/"
@ -281,7 +281,7 @@ func unsubscribeLive(buid, groupid int64) (err error) {
}
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 {
log.Errorln("[bilibilipush]:", err)
}
@ -345,11 +345,12 @@ func sendDynamic() {
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
if gid > 0 {
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
} else if gid < 0 {
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
} else {
default:
log.Errorln("[bilibilipush]:gid为0")
}
}
@ -398,11 +399,12 @@ func sendLive() {
zero.RangeBot(func(id int64, ctx *zero.Ctx) bool {
for _, gid := range groupList {
if m.IsEnabledIn(gid) {
if gid > 0 {
switch {
case gid > 0:
ctx.SendGroupMessage(gid, msg)
} else if gid < 0 {
case gid < 0:
ctx.SendPrivateMessage(-gid, msg)
} else {
default:
log.Errorln("[bilibilipush]:gid为0")
}
}
@ -410,6 +412,8 @@ func sendLive() {
return true
})
}
} else if newStatus != oldStatus {
liveStatus[key.Int()] = newStatus
}
return true
})

View File

@ -53,21 +53,6 @@ func initialize(dbpath string) *bilibilipushdb {
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 插入或更新数据库
func (bdb *bilibilipushdb) insertOrUpdateLiveAndDynamic(bpMap map[string]interface{}) (err error) {
db := (*gorm.DB)(bdb)