Cookie string
Title string
Rev float64//营收
+ Renqi int//人气
+ GuardNum int//舰长数
Live_Start_Time time.Time//直播开始时间
Liveing bool//是否在直播
)
o.Live_status = live_status.(float64)
switch live_status.(float64) {
case 2:
+ c.Liveing = false
apilog.W("轮播中")
return
case 0: //未直播
+ c.Liveing = false
apilog.W("未在直播")
return
case 1:
return rface.(string) + `@58w_58h`
}
+var user_score_map = make(map[string]float64)
func (i *api) Get_OnlineGoldRank() {
if i.Uid == 0 || c.Roomid == 0 {
apilog.Base(1, "Get_OnlineGoldRank").E("i.Uid == 0 || c.Roomid == 0")
return
}
var session_roomid = c.Roomid
- var self_loop func(page int)(score float64)
- self_loop = func(page int)(score float64){
+ var self_loop func(page int)
+ self_loop = func(page int){
if page <= 0 || session_roomid != c.Roomid{return}
// apilog.Base(1, "self_loop").E(page)
} else {
tmp_onlineNum := onlineNum.(float64)
if tmp_onlineNum == 0 {
- apilog.Base(1, "获取tmp_onlineNum").E("tmp_onlineNum", tmp_onlineNum)
+ // apilog.Base(1, "获取tmp_onlineNum").E("tmp_onlineNum", tmp_onlineNum)
return
}
+ var score = 0.0
if tmp_score_list := p.Json().GetArrayFrom(p.Json().GetValFromS(res, "data.OnlineRankItem"), "score");len(tmp_score_list) != 0 {
for _,v := range tmp_score_list {
score += v.(float64)/10
Data:score,
})
- if rank_list := p.Json().GetArrayFrom(p.Json().GetValFromS(res, "data.OnlineRankItem"), "userRank");len(rank_list) == 0 {
+ if rank_list := p.Json().GetArrayFrom(p.Json().GetValFromS(res, "data.OnlineRankItem"), "userRank");rank_list == nil {
apilog.Base(1, "获取 rank_list").E("rank_list", len(rank_list))
return
- } else if rank_list[len(rank_list)-1].(float64) == tmp_onlineNum {
+ } else if len(rank_list) == 0 {
// apilog.Base(1, "获取 rank_list").E("rank_list == tmp_onlineNum")
return
} else {
// apilog.Base(1, "获取score").E("score", self_loop(1))
self_loop(1)
- apilog.Base(1, "获取score").E("以往营收获取成功")
+ apilog.Base(1, "获取score").W("以往营收获取成功", c.Rev)
// c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
// Class:`c.Rev_add`,
// Data:self_loop(1),
// })
return
-}
\ No newline at end of file
+}
+
+func (i *api) Get_guardNum() {
+ if i.Uid == 0 || c.Roomid == 0 {
+ apilog.Base(1, "Get_guardNum").E("i.Uid == 0 || c.Roomid == 0")
+ return
+ }
+
+ req := p.Req()
+ if err := req.Reqf(p.Rval{
+ Url:`https://api.live.bilibili.com/xlive/app-room/v2/guardTab/topList?roomid=`+strconv.Itoa(c.Roomid)+`&page=1&ruid=`+strconv.Itoa(i.Uid)+`&page_size=29`,
+ 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`,
+ `Accept`: `application/json, text/plain, */*`,
+ `Accept-Language`: `zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2`,
+ `Accept-Encoding`: `gzip, deflate, br`,
+ `Origin`: `https://live.bilibili.com`,
+ `Connection`: `keep-alive`,
+ `Pragma`: `no-cache`,
+ `Cache-Control`: `no-cache`,
+ `Referer`:"https://live.bilibili.com/" + strconv.Itoa(c.Roomid),
+ },
+ Timeout:3,
+ Retry:2,
+ });err != nil {
+ apilog.Base(1, "获取guardNum").E(err)
+ return
+ }
+ res := string(req.Respon)
+ if msg := p.Json().GetValFromS(res, "message");msg == nil || msg != "0" {
+ apilog.Base(1, "获取guardNum").E("message", msg)
+ return
+ }
+ if num := p.Json().GetValFromS(res, "data.info.num");num == nil {
+ apilog.Base(1, "获取num").E("num", num)
+ return
+ } else {
+ c.GuardNum = int(num.(float64))
+ apilog.Base(1, "获取guardNum").W("舰长数获取成功", c.GuardNum)
+ }
+ return
+}
package reply
import (
- "strconv"
-
p "github.com/qydysky/part"
F "github.com/qydysky/bili_danmu/F"
)
var heartlog = p.Logf().New().Base(-1, "Heart.go").Open("danmu.log").Fileonly(true)
//HeartBeat类型处理方法map
-var Heart_map = map[string]func(replyF, string) {
+var Heart_map = map[string]func(replyF, int) {
"heartbeat":replyF.heartbeat,//人气
}
//HeartBeat类型,将人气4位byte转为字符串,并送到上述map指定的方法
func Heart(b []byte){
- s := strconv.Itoa(int(F.Btoi32(b, 0)))
+ s := int(F.Btoi32(b, 0))
if F,ok := Heart_map["heartbeat"]; ok {
var f replyF
F(f, s);
//Msg类型数据处理方法map
var Msg_map = map[string]func(replyF, string) {
+ `WIDGET_BANNER`:nil,//每日任务
`ROOM_ADMINS`:nil,//房管列表
`room_admin_entrance`:nil,
`ONLINE_RANK_TOP3`:nil,
Assf(fmt.Sprintln("天选之人", award_name, "开始"))
}
fmt.Println(sh...)
- Gui_show(Itos(sh))
+ Gui_show(Itos(sh),`0tianxuan`)
msglog.Base(1, "房").Fileonly(true).I(sh...).Fileonly(false)
}
Assf(fmt.Sprintln("天选之人", award_name, "结束"))
}
fmt.Println(sh...)
- Gui_show(Itos(sh))
+ Gui_show(Itos(sh),`0tianxuan`)
msglog.Base(1, "房").Fileonly(true).I(sh...).Fileonly(false)
}
switch op_type.(float64) {
case 1:
sh = append(sh, "购买了")
+ c.GuardNum += 1
case 2:
sh = append(sh, "续费了")
case 3:
sh = append(sh, "自动续费了")
+ c.GuardNum += 1
default:
msglog.W(s)
sh = append(sh, op_type)
}
//HeartBeat-心跳用来传递人气值
-func (replyF) heartbeat(s string){
- if s == "1" {return}//人气为1,不输出
+func (replyF) heartbeat(s int){
+ c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{
+ Class:`c.Renqi`,
+ Data:s,
+ })
+ // if s == "1" {return}//人气为1,不输出
heartlog.I("当前人气", s)
}
sh = append(sh, "节奏风暴", content, "¥ 100")
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
- Data:100,
+ Data:float64(100),
})
}
{//额外
total_coin := p.Json().GetValFromS(s, "data.total_coin");
var sh []interface{}
- var allprice int64
+ var allprice float64
if uname != nil {
sh = append(sh, uname)
sh = append(sh, giftName)
}
if total_coin != nil {
- allprice = int64(total_coin.(float64) / 1000)
- sh = append(sh, "¥", allprice)
+ allprice = total_coin.(float64) / 1000
+ sh = append(sh, fmt.Sprintf("¥%.1f",allprice))
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
- Data:total_coin.(float64) / 1000,
+ Data:allprice,
})
}
if uname != nil {
sh = append(sh, uname)
}
+ logg := sh
if price != nil {
sh = append(sh, "¥", price, "\n")
+ logg = append(logg, "¥", price)
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
Data:price.(float64),
fmt.Println(message)
// Gui_show(message.(string))
sh = append(sh, message)
+ logg = append(logg, message)
}
if message_jpn != nil && message.(string) != message_jpn.(string) && message_jpn.(string) != "" {
fmt.Println(message_jpn)
// Gui_show(message_jpn.(string))
sh = append(sh, message_jpn)
+ logg = append(logg, message_jpn)
}
fmt.Print("====\n\n")
// Gui_show("====\n")
Gui_show(Itos(sh), "0superchat")
}
- msglog.Base(1, "礼").Fileonly(true).I(sh...).Fileonly(false)
+ msglog.Base(1, "礼").Fileonly(true).I(logg...).Fileonly(false)
}
//Msg-分区排行
//传入字符串即可发送
//需要cookie
func Msg_senddanmu(msg string){
- if c.Cookie == "" || c.Roomid == 0 {return}
+ if c.Cookie == "" || c.Roomid == 0 {
+ msglog.I(`c.Cookie == "" || c.Roomid == 0`)
+ return
+ }
S.Danmu_s(msg, c.Cookie, c.Roomid)
}
"face/0level2":3,
"face/0level3":1,
"face/0superchat":13,
+ "face/0tianxuan":5,
}
var (
Gtk_on bool
var viewport0 *gtk.Viewport
var w2_textView0 *gtk.TextView
var w2_textView1 *gtk.TextView
+ var w2_textView2 *gtk.TextView
+ var w2_textView3 *gtk.TextView
+ var renqi_old = 1
var w2_Entry0 *gtk.Entry
var w2_Entry0_editting bool
w2_textView1 = tmp
}else{log.Println("cant find #t1 in .glade");return}
}
+ {//人气值
+ obj, err := builder2.GetObject("t2")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.TextView); ok {
+ w2_textView2 = tmp
+ }else{log.Println("cant find #t2 in .glade");return}
+ }
+ {//舰长数
+ obj, err := builder2.GetObject("t3")
+ if err != nil {log.Println(err);return}
+ if tmp,ok := obj.(*gtk.TextView); ok {
+ w2_textView3 = tmp
+ }else{log.Println("cant find #t3 in .glade");return}
+ }
{//发送弹幕
var danmu_send_form string
{//发送弹幕格式
y(`输入错误`,load_face("0room"))
} else {
c.Roomid = i
+ renqi_old = 1//人气置1
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{
Class:`change_room`,
})
b.SetText(fmt.Sprintf("¥%.2f",c.Rev))
}
}
+ {//舰长
+ b,e := w2_textView3.GetBuffer()
+ if e != nil {log.Println(e);return}
+ b.SetText(fmt.Sprintf("%d",c.GuardNum))
+ }
{//时长
+ b,e := w2_textView1.GetBuffer()
+ if e != nil {log.Println(e);return}
if c.Liveing {
- b,e := w2_textView1.GetBuffer()
- if e != nil {log.Println(e);return}
d := time.Since(c.Live_Start_Time).Round(time.Second)
h := d / time.Hour
d -= h * time.Hour
m := d / time.Minute
d -= m * time.Minute
s := d / time.Second
- b.SetText(fmt.Sprintf("%02d:%02d:%02d", h, m, s))
+ b.SetText(fmt.Sprintf("%02d:%02d:%02d", h, m, s))
+ } else {
+ b.SetText("00:00:00")
+ }
+ }
+ {//人气
+ b,e := w2_textView2.GetBuffer()
+ if e != nil {log.Println(e);return}
+ if c.Liveing {
+ if c.Renqi != renqi_old {
+ var Renqi string = strconv.Itoa(c.Renqi)
+ L:=len([]rune(Renqi))
+
+ var tmp string
+ if renqi_old != 1 {
+ if c.Renqi > renqi_old {tmp += `+`}
+ tmp += fmt.Sprintf("%.1f",100*float64(c.Renqi - renqi_old)/float64(renqi_old)) + `% | `
+ }
+ if c.Renqi != 0 {renqi_old = c.Renqi}
+
+ for k,v := range []rune(Renqi) {
+ tmp += string(v)
+ if (L - k)%3 == 1 && L - k != 1{
+ tmp += `,`
+ }
+ }
+ b.SetText(tmp)
+ }
+ } else {
+ b.SetText(`0`)
}
}
{//房间id
switch d.Class {
case `change_room`:
c.Rev = 0 //营收
+ c.Renqi = 1//人气置1
change_room_chan <- true
case `c.Rev_add`:
c.Rev += d.Data.(float64)
+ case `c.Renqi`:
+ c.Renqi = d.Data.(int)
default:
}
}
c.Roomid = api.Roomid
c.Live = api.Live
c.Cookie = f
- //获取过往营收
+ //获取过往营收 舰长数量
go api.Get_OnlineGoldRank()
+ go api.Get_guardNum()
if p.Checkfile().IsExist("cookie.txt") {//附加功能 弹幕机
reply.Danmuji_auto(1)
"face/0level1":5,
"face/0level2":3,
"face/0level3":1,
- "face/0superchat":13
+ "face/0superchat":13,
+ "face/0tianxuan":5
}
\ No newline at end of file
<object class="GtkTextView" id="t0">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="hscroll_policy">natural</property>
<property name="editable">False</property>
<property name="justification">right</property>
<property name="cursor_visible">False</property>
<property name="top_attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">人气</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="t2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="justification">right</property>
+ <property name="cursor_visible">False</property>
+ <property name="accepts_tab">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">舰长数</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkTextView" id="t3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="justification">right</property>
+ <property name="cursor_visible">False</property>
+ <property name="accepts_tab">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
<style>
<class name="this_time_body"/>
</style>