Class string
Data interface{}
}
-var Danmu_Main_mq = mq.New()
+var Danmu_Main_mq = mq.New(10)
//from player-loader-2.0.11.min.js
/*
### 构建
本项目使用github action自动构建,构建过程详见[yml](https://github.com/qydysky/bili_danmu/blob/master/.github/workflows/go.yml)
+构建tts需要ffplay,先行安装[ffmpeg](http://ffmpeg.org/download.html)
+
+```
+编译命令
+cd demo
+go build -v -tags `tts` -o demo.exe -i main.go
+```
+
+构建gtk需要gtk3,先行安装[gtk](https://www.gtk.org/)
+```
+编译命令
+cd demo
+go build -v -tags `gtk gtk_3_24` -o demo.exe -i main.go
+```
### demo
前往[releases](https://github.com/qydysky/bili_danmu/releases)页下载对应系统版本。解压后进入`demo`目录(文件夹),运行`demo.run`(`demo.exe`)。
```
F "github.com/qydysky/bili_danmu/F"
"github.com/christopher-dG/go-obs-websocket"
p "github.com/qydysky/part"
+ s "github.com/qydysky/part/signal"
)
/*
//直播流保存
type Saveflv struct {
path string
- wait p.Signal
- cancel p.Signal
+ wait *s.Signal
+ cancel *s.Signal
}
var saveflv = Saveflv {
saveflv.path = strconv.Itoa(c.Roomid) + "_" + time.Now().Format("2006_01_02_15:04:05.000")
- saveflv.wait.Init()
- saveflv.cancel.Init()
+ saveflv.wait = s.Init()
+ saveflv.cancel = s.Init()
rr := p.Req()
go func(){
price := p.Json().GetValFromS(s, "data.price");
var sh []interface{}
+ var sh_log []interface{}
if username != nil {
sh = append(sh, username)
}
}
if num != nil {
- sh = append(sh, num, "x")
+ sh = append(sh, num, "个")
}
if unit != nil {
sh = append(sh, unit)
sh = append(sh, role_name)
}
if price != nil {
- sh = append(sh, "¥", int(price.(float64)) / 1000)
+ sh_log = append(sh, "¥", int(price.(float64)) / 1000)//不在界面显示价格
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
Data:price.(float64) / 1000,
Gui_show(Itos(sh), "0buyguide")
// Gui_show("====\n")
- msglog.Base(1, "礼").Fileonly(true).I(sh...).Fileonly(false)
+ msglog.Base(1, "礼").Fileonly(true).I(sh_log...).Fileonly(false)
}
//HeartBeat-心跳用来传递人气值
price := p.Json().GetValFromS(s, "data.price");
var sh []interface{}
+ var sh_log []interface{}
if username != nil {
sh = append(sh, username)
sh = append(sh, "购买了", gift_name)
}
if price != nil {
- sh = append(sh, "¥", int(price.(float64)) / 1000)
+ sh_log = append(sh, "¥", int(price.(float64)) / 1000)//不在界面显示价格
}
{//额外 ass
Assf(fmt.Sprintln(sh...))
fmt.Println("\n====")
fmt.Println(sh...)
fmt.Print("====\n\n")
+ msglog.Base(1, "礼").Fileonly(true).I(sh_log...).Fileonly(false)
- msglog.Base(1, "礼").Fileonly(true).I(sh...).Fileonly(false)
}
//Msg-房间信息改变,标题等
total_coin := p.Json().GetValFromS(s, "data.total_coin");
var sh []interface{}
+ var sh_log []interface{}
var allprice float64
if uname != nil {
sh = append(sh, action)
}
if num != nil {
- sh = append(sh, num, "x")
+ sh = append(sh, num, "个")
}
if giftName != nil {
sh = append(sh, giftName)
}
if total_coin != nil {
allprice = total_coin.(float64) / 1000
- sh = append(sh, fmt.Sprintf("¥%.1f",allprice))
+ sh_log = append(sh, fmt.Sprintf("¥%.1f",allprice))//不在界面显示价格
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
Data:allprice,
}
if len(sh) == 0 {return}
- msglog.Base(1, "礼").Fileonly(true).I(sh...).Fileonly(false)
+ msglog.Base(1, "礼").Fileonly(true).I(sh_log...).Fileonly(false)
//小于3万金瓜子
if allprice < 30 {msglog.T(sh...);return}
}
logg := sh
if price != nil {
- sh = append(sh, "¥", price, "\n")
+ sh = append(sh, "\n")//界面不显示价格
logg = append(logg, "¥", price)
c.Danmu_Main_mq.Push(c.Danmu_Main_mq_item{//传入消息队列
Class:`c.Rev_add`,
uid string
msg string
}
-var Danmu_mq = mq.New()
+var Danmu_mq = mq.New(10)
func Gui_show(m ...string){
//m[0]:msg m[1]:uid
var old_cu float64
{//平滑滚动效果
tmp := scrolledwindow0.GetVAdjustment()
- h := viewport0.GetViewWindow().WindowGetHeight()
glib.TimeoutAdd(uint(30),func()(true_value bool){
true_value = true
if !in_smooth_roll {return}
- g1h := viewport1.GetViewWindow().WindowGetHeight()
- max := tmp.GetUpper() - float64(h - g1h)
+ h := viewport0.GetViewWindow().WindowGetHeight()
+ // g1h := viewport1.GetViewWindow().WindowGetHeight()
+ max := tmp.GetUpper() - float64(h)
cu := tmp.GetValue()
//用户在回看
if old_cu != 0 &&//非初始
- max - 100 > cu &&//当前位置低于max-100
+ max - cu > 100 &&//当前位置低于100
old_cu != cu {//上一次滚动有移动
return
}
case `change_room`:
c.Rev = 0.0 //营收
c.Renqi = 1//人气置1
+ c.Title = ``
change_room_chan <- true
case `c.Rev_add`:
c.Rev += d.Data.(float64)
github.com/miekg/dns v1.1.35 // indirect
github.com/mitchellh/mapstructure v1.4.0 // indirect
github.com/qydysky/bili_danmu v0.5.2
- github.com/qydysky/part v0.3.1 // indirect
+ github.com/qydysky/part v0.3.3 // indirect
+ github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad // indirect
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c // indirect
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb // indirect
github.com/qydysky/part v0.2.2-0.20201119032922-a6f2c3476095/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4=
github.com/qydysky/part v0.3.1 h1:pyRSZQCWPsMSmn3XcEGFdwfhTdMczDomHi2+pfoiBdU=
github.com/qydysky/part v0.3.1/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4=
+github.com/qydysky/part v0.3.2 h1:P+OKyv2doQoXlTQev2AjSL2MvoX2PLcJBRRDlSnpm94=
+github.com/qydysky/part v0.3.2/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4=
+github.com/qydysky/part v0.3.3 h1:Xbz61YzHfEbeNZ5Fz1IxS6ktkV0Nk9bDsrxGWsKD9hE=
+github.com/qydysky/part v0.3.3/go.mod h1:93s9ohLtzULet5ZPEUUWrT9BELC30oDZgRpgGSiDye4=
+github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad h1:Jtzf509lQrkUMGTV0Sc6IDCAiR1VrBcHrIban7hpye4=
+github.com/qydysky/part/msgq v0.0.0-20201213031129-ca3253dc72ad/go.mod h1:w32TkJNVtTJd4LOS09cq+4uYG6itcN2vsqw+slp44Rg=
github.com/shirou/gopsutil v2.20.7+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/gopsutil v2.20.8+incompatible h1:8c7Atn0FAUZJo+f4wYbN0iVpdWniCQk7IYwGtgdh1mY=
github.com/shirou/gopsutil v2.20.8+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
<property name="window_position">mouse</property>
<property name="default_width">400</property>
<property name="default_height">500</property>
+ <child>
+ <placeholder/>
+ </child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="margin_top">2</property>
<property name="orientation">vertical</property>
<property name="row_spacing">3</property>
<property name="column_spacing">2</property>
c "github.com/qydysky/bili_danmu/CV"
p "github.com/qydysky/part"
+ s "github.com/qydysky/part/signal"
)
type ws struct {
- Signal p.Signal
+ Signal *s.Signal
SendChan chan []byte
RecvChan chan []byte
TO int
defer l.Block()
if o.Signal.Islive() {return}
- o.Signal.Init()
+ o.Signal = s.Init()
if o.url == "" {
l.E("o.url == \"\"")