]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
没牌就不戴
authorqydysky <qydysky@foxmail.com>
Sun, 20 Dec 2020 13:57:30 +0000 (21:57 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 20 Dec 2020 13:57:30 +0000 (21:57 +0800)
F/api.go
README.md

index ee61ec695953be1dfe0f3e1a967a5324606802df..8d54e060f4961a32596a1304ffdc36c22796f82a 100644 (file)
--- a/F/api.go
+++ b/F/api.go
@@ -774,9 +774,12 @@ func (i *api) Switch_FansMedal() {
                                return
                        }
                }
-               if medal_id == 0 {return}
        }
-       {//切换牌子
+       var (
+               post_url string
+               post_str string
+       )
+       {//生成佩戴信息
                var csrf string
                if i := strings.Index(c.Cookie, "bili_jct="); i == -1 {
                        apilog.Base(1,`Switch_FansMedal`).E("Cookie错误,无bili_jct=")
@@ -788,10 +791,19 @@ func (i *api) Switch_FansMedal() {
                                csrf = c.Cookie[i + 9:][:d]
                        }
                }
+               post_str = `csrf_token=`+csrf+`&csrf=`+csrf
+               if medal_id == 0 {//无牌,不佩戴牌子
+                       post_url = `https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/take_off`
+               } else {
+                       post_url = `https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/wear`
+                       post_str = `medal_id=`+strconv.Itoa(medal_id)+`&`+post_str
+               }
+       }
+       {//切换牌子
                r := p.Req()
                if e := r.Reqf(p.Rval{
-                       Url:`https://api.live.bilibili.com/xlive/web-room/v1/fansMedal/wear`,
-                       PostStr:`medal_id=`+strconv.Itoa(medal_id)+`&csrf_token=`+csrf+`&csrf=`+csrf,
+                       Url:post_url,
+                       PostStr:post_str,
                        Header:map[string]string{
                                `Cookie`:c.Cookie,
                                `Content-Type`:`application/x-www-form-urlencoded; charset=UTF-8`,
index c1558a0f96fcf2a46a22c362b348d9479d7b3bfb..930b0aefdaaad4344df47ec61a0018a394c712ba 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,6 +58,7 @@ golang go version go1.15.5 linux/amd64
 
 #### 当前支持功能
 以下内容可能过时,点击查看[当前支持功能](https://github.com/qydysky/bili_danmu/blob/master/Reply/F.go#L16)
+- [x] 自动切换粉丝牌
 - [x] 扫码登录
 - [x] 自定义语音提醒
 - [x] GTK弹幕窗