]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
保持当前已点亮的粉丝牌总是点亮
authorqydysky <qydysky@foxmail.com>
Mon, 8 Mar 2021 04:59:41 +0000 (12:59 +0800)
committerqydysky <qydysky@foxmail.com>
Mon, 8 Mar 2021 04:59:51 +0000 (12:59 +0800)
F/api.go
README.md
Reply/F.go
Send/Send.go

index 837425003cffa02c5dc48c935e53b6ba9c53df5e..a3ff14562fa060db0d97f2f892d7cdfbb1024f7b 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -936,7 +936,8 @@ type TGet_list_in_room struct{
        Medal_name string `json:"medal_name"`//牌子名
        Target_id int `json:"target_id"`//牌子up主uid
        Target_name string `json:"target_name"`//牌子up主名
-       Room_id int `json:"room_id"`//牌子直播间
+       Room_id int `json:"roomid"`//牌子直播间
+       Last_wear_time int `json:"last_wear_time"`//上次佩戴时间
        Today_intimacy int `json:"today_intimacy"`//今日亲密(0:未发送弹幕 100:已发送弹幕)
        Is_lighted int `json:"is_lighted"`//牌子是否熄灭(0:熄灭 1:亮)
 }
@@ -960,36 +961,52 @@ func Get_list_in_room() (array []TGet_list_in_room) {
        })
 
        {//获取牌子列表
-               r := p.Req()
-               if e := r.Reqf(p.Rval{
-                       Url:`https://api.live.bilibili.com/fans_medal/v1/FansMedal/get_list_in_room`,
-                       Header:map[string]string{
-                               `Cookie`:p.Map_2_Cookies_String(Cookie),
-                       },
-                       Timeout:10,
-                       Retry:2,
-               });e != nil {
-                       apilog.L(`E: `,e)
-                       return
-               }
-               
-               var res struct{
-                       Code int `json:"code"`
-                       Msg string `json:"msg"`
-                       Message string `json:"message"`
-                       Data []TGet_list_in_room `json:"data"`
-               }
+               var medalList []TGet_list_in_room
+               for pageNum:=1; true;pageNum+=1{
+                       r := p.Req()
+                       if e := r.Reqf(p.Rval{
+                               Url:`https://api.live.bilibili.com/fans_medal/v5/live_fans_medal/iApiMedal?page=`+strconv.Itoa(pageNum)+`&pageSize=10`,
+                               Header:map[string]string{
+                                       `Cookie`:p.Map_2_Cookies_String(Cookie),
+                               },
+                               Timeout:10,
+                               Retry:2,
+                       });e != nil {
+                               apilog.L(`E: `,e)
+                               return
+                       }
+                       
+                       var res struct{
+                               Code int `json:"code"`
+                               Msg string `json:"msg"`
+                               Message string `json:"message"`
+                               Data struct{
+                                       FansMedalList []TGet_list_in_room `json"fansMedalList"`
+                                       Pageinfo struct{
+                                               Totalpages int `json:"totalpages"`
+                                               CurPage int `json:"curPage"`
+                                       } `json:"pageinfo"`
+                               } `json:"data"`
+                       }
+       
+                       if e := json.Unmarshal(r.Respon, &res);e != nil{
+                               apilog.L(`E: `,e)
+                       }
+       
+                       if res.Code != 0 {
+                               apilog.L(`E: `,`返回code`, res.Code, res.Msg)
+                               return
+                       }
 
-               if e := json.Unmarshal(r.Respon, &res);e != nil{
-                       apilog.L(`E: `,e)
-               }
+                       medalList = append(medalList, res.Data.FansMedalList...)
 
-               if res.Code != 0 {
-                       apilog.L(`E: `,`返回code`, res.Code, res.Msg)
-                       return
+                       if res.Data.Pageinfo.CurPage == res.Data.Pageinfo.Totalpages {break}
+
+                       time.Sleep(time.Second)
                }
+               
 
-               return res.Data
+               return medalList
        }
 }
 
index b826fd03f481d0b0dbd139ca8f6daa0e1b7bc784..226e44ec90830fdabd1ed8c7ee2c83e6748f3553 100644 (file)
--- a/README.md
+++ b/README.md
@@ -59,12 +59,12 @@ golang go version go1.15 linux/amd64
 
 #### 当前支持功能
 以下内容可能过时,点击查看[~~当前支持功能(旧)~~](https://github.com/qydysky/bili_danmu/blob/9731f69d06a15645c6cb1d41379520a5a3f519f1/Reply/F.go#L26),[功能配置(新)](https://github.com/qydysky/bili_danmu/blob/maintenance/demo/config/config_K_v.json)
-- [x] 自动发送将要过期的银瓜子礼物(默认发送3天内过期的)(日期更迭会触发)
-- [x] 保持自选(手机25个(最多)自选)粉丝牌总是点亮(日期更迭会触发)
-- [x] 银瓜子自动兑换硬币(日期更迭会触发)
-- [x] 发进房弹幕(可选有无粉丝牌(可选每日首次发送后不发))(日期更迭会触发)
-- [x] 签到(日期更迭会触发)
-- [x] æ\9c\89ç²\89ä¸\9dç\89\8cè\8e·å\8f\96å°\8få¿\83å¿\83\97¥æ\9c\9fæ\9b´è¿­ä¼\9a触å\8f\91)
+- [x] 每天自动发送将要过期的银瓜子礼物(默认发送3天内过期的)
+- [x] 保持当前已点亮的粉丝牌总是点亮
+- [x] 银瓜子自动兑换硬币
+- [x] 发进房弹幕(可选有无粉丝牌(可选每日首次发送后不发))
+- [x] 每日签到
+- [x] æ¯\8fæ\97¥æ\9c\89ç²\89ä¸\9dç\89\8cè\8e·å\8f\96å°\8få¿\83å¿\83
 - [x] 自定义私信
 - [x] 自动切换粉丝牌
 - [x] 扫码登录
@@ -100,10 +100,12 @@ golang go version go1.15 linux/amd64
 #### 命令行操作
 在准备动作完成(`T: 2021/03/06 16:22:39 命令行操作 [回车查看帮助]`)后,输入回车将显示帮助
 ```
-I: 2021/03/06 16:16:17 命令行操作 [切换房间->输入数字回车]
-I: 2021/03/06 16:16:17 命令行操作 [发送弹幕->输入' 字符串'回车]
-I: 2021/03/06 16:16:17 命令行操作 [查看直播中主播->输入' live'回车]
-I: 2021/03/06 16:16:17 命令行操作 [其他输出隔断不影响]
+I: 2021/03/08 12:57:09 命令行操作 [切换房间->输入数字回车]
+I: 2021/03/08 12:57:09 命令行操作 [发送弹幕->输入' 字符串'回车]
+I: 2021/03/08 12:57:09 命令行操作 [房间信息->输入' room'回车]
+I: 2021/03/08 12:57:09 命令行操作 [查看直播中主播->输入' live'回车]
+I: 2021/03/08 12:57:09 命令行操作 [其他输出隔断不影响]
+
 ```
 用例:
 - 直播间切换
@@ -128,6 +130,16 @@ I: 2021/03/06 16:21:35 命令行操作 [进入 120]
  1
 I: 2021/03/06 16:21:17 弹幕发送 [发送 1 至 7734200]
 ```
+- 查看房间信息
+```
+ room
+I: 2021/03/08 01:06:53 命令行操作 [当前直播间信息]
+I: 2021/03/08 01:06:53 命令行操作 [C酱です 213电竞俱乐部开业了! 直播中]
+I: 2021/03/08 01:06:53 命令行操作 [已直播时长: 07:56:53]
+I: 2021/03/08 01:06:53 命令行操作 [营收: ¥0.00]
+I: 2021/03/08 01:06:53 命令行操作 [舰长数: 1427]
+I: 2021/03/08 01:06:53 命令行操作 [分区排行: 单机游戏 19 人气: 1321956]
+```
 #### cookie加密
 保护cookie.txt
 
index 02da059432b1e08b7a797f8e8563b99a27278895..a47d5f252796304fb4dbae33f8a7705a8e5d48af 100644 (file)
@@ -779,7 +779,7 @@ func Keep_medal_light() {
 
        for _,v := range F.Get_list_in_room() {
                if v.Is_lighted == 1 {continue}
-               
+               if time.Now().Add(-time.Hour * time.Duration(24 * 7)).Unix() - int64(v.Last_wear_time) > 0 {continue}
                send.Danmu_s(sendStr,p.Map_2_Cookies_String(Cookie),v.Room_id)
                time.Sleep(time.Second)
        }
index 578d7a6387aa87b19cd0d93edc8c7e3c82c6e08a..2d62e21e8cac41d9271eae2c75118ceae1f61618 100644 (file)
@@ -3,6 +3,7 @@ package send
 import (
        "strings"
        "strconv"
+       "encoding/json"
 
        c "github.com/qydysky/bili_danmu/CV"
        p "github.com/qydysky/part"
@@ -44,7 +45,8 @@ func Danmu_s(msg,Cookie string, roomid int) {
        err := r.Reqf(p.Rval{
                Url:"https://api.live.bilibili.com/msg/send",
                PostStr:PostStr,
-               Timeout:5,
+               Retry:2,
+               Timeout:10,
                Header:map[string]string{
                        `Host`: `api.live.bilibili.com`,
                        `User-Agent`: `Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0`,
@@ -65,13 +67,18 @@ func Danmu_s(msg,Cookie string, roomid int) {
                return
        }
        
-       if code := p.Json().GetValFromS(string(r.Respon), "code");code == nil || code.(float64) != 0 {
-               if message := p.Json().GetValFromS(string(r.Respon), "message");message != nil {
-                       l.L(`E: `,message)
-               } else {
-                       l.L(`E: `,string(r.Respon))
-               }
-               return
+       var res struct{
+               Code int `json:"code"`
+               Message string `json:"message"`
+       }
+
+       if e := json.Unmarshal(r.Respon, &res);e != nil{
+               l.L(`E: `,e)
+       }
+
+       if res.Code != 0 {
+               l.L(`E: `, res.Code, res.Message)
        }
+       l.L(`E: `, res.Message)
 
 }
\ No newline at end of file