]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
效率优化
authorqydysky <qydysky@foxmail.com>
Tue, 5 Jan 2021 16:26:02 +0000 (00:26 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 5 Jan 2021 16:26:02 +0000 (00:26 +0800)
CV/Var.go
README.md
Send/README.md
Send/Send_pm.go
bili_danmu.go
demo/config/README.md
demo/face/0multi [new file with mode: 0644]
demo/face/README.md
demo/go.mod
demo/go.sum
demo/main.go

index 5c7daf93af299383ed576e2d56baae2ee5d6cc53..c3341d822929453b151ff9ab077509d2f0c6cedc 100644 (file)
--- a/CV/Var.go
+++ b/CV/Var.go
@@ -29,7 +29,8 @@ type Danmu_Main_mq_item struct {
        Class string
        Data interface{}
 }
-var Danmu_Main_mq = mq.New(10)
+//200长度防止push击穿
+var Danmu_Main_mq = mq.New(200)
 
 //日志
 var Log = log.New(log.Config{
index 1b0b101da984b0fff8932c4caed2c14514df8d58..066297bb859634d8f343be3f3743f69e46744d75 100644 (file)
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ golang go version go1.15.5 linux/amd64
 - [github.com/christopher-dG/go-obs-websocket](https://github.com/christopher-dG/go-obs-websocket) under [MIT](https://raw.githubusercontent.com/christopher-dG/go-obs-websocket/master/LICENSE)
 - [github.com/gorilla/websocket](https://github.com/gorilla/websocket) under [BSD 2-Clause](https://raw.githubusercontent.com/gorilla/websocket/master/LICENSE)
 - [github.com/skip2/go-qrcode](https://github.com/skip2/go-qrcode) under [MIT](https://github.com/skip2/go-qrcode/blob/master/LICENSE)
+- [github.com/gofrs/uuid](https://github.com/gofrs/uuid) under [MIT](https://github.com/gofrs/uuid/blob/master/LICENSE)
 - [7z](https://www.7-zip.org/) under [LICENSE](https://www.7-zip.org/license.txt)
 ---
 
@@ -57,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] 自定义语音提醒
index 3df4e43c47b2c8d12f2745e52280fa470316f718..57d87240350125185a71d9c2a414a482ea2bd03b 100644 (file)
@@ -5,4 +5,5 @@
 |-|-|
 |./|弹幕发送|
 |Send.go|弹幕发送|
+|Send_pm.go|私信发送|
 ---
\ No newline at end of file
index 71a631c97854817ee54136d59207f3e13d88e631..f74a5f29088c246d0052f2a27fc04fb7c405b3bc 100644 (file)
@@ -19,13 +19,12 @@ type Pm_item struct {
 var pm_limit = p.Limit(1, 5000, 10000)
 
 func Send_pm(uid int, msg string) error {
-       if pm_limit.TO() {return errors.New("TO")}
-       log := c.Log.Base_add(`私信`)
-       
        if msg == `` || uid == 0 {
                return errors.New(`msg == "" || uid == 0`)
        }
 
+       log := c.Log.Base_add(`私信`)
+
        if c.Uid == 0 {
                log.L(`E: `,`client uid == 0`)
                return errors.New(`client uid == 0`)
@@ -56,6 +55,8 @@ func Send_pm(uid int, msg string) error {
                }
        }
 
+       if pm_limit.TO() {return errors.New("TO")}
+
        var send_str = `msg[sender_uid]=`+strconv.Itoa(c.Uid)+`&msg[receiver_id]=`+strconv.Itoa(uid)+`&msg[receiver_type]=1&msg[msg_type]=1&msg[msg_status]=0&msg[content]={"content":"`+msg+`"}&msg[timestamp]=`+strconv.Itoa(int(p.Sys().GetSTime()))+`&msg[new_face_version]=0&msg[dev_id]=`+strings.ToUpper(new_uuid)+`&from_firework=0&build=0&mobi_app=web&csrf_token=`+csrf+`&csrf=`+csrf
        
        req := p.Req()
index ae5d03ae3a44e7c8bab4b75970f83c72425c06ad..00c980c12e1797e3dc66f090b0ddc81d6deccc38 100644 (file)
@@ -32,7 +32,7 @@ func Demo(roomid ...int) {
                if _,ok := c.Default_qn[*live_qn]; ok{c.Live_qn = *live_qn}
 
                var exit_sign bool
-               var change_room_chan = make(chan bool,1)
+               var change_room_chan = make(chan struct{})
 
                go func(){
                        var room = *groomid
@@ -51,7 +51,7 @@ func Demo(roomid ...int) {
                        }
                        if c.Roomid == 0 {
                                c.Roomid = room
-                               change_room_chan <- true
+                               change_room_chan <- struct{}{}
                        }
                }()
                
@@ -65,7 +65,8 @@ func Demo(roomid ...int) {
                                c.Uname = ``//主播id
                                c.Title = ``
                                reply.Saveflv_wait()//停止保存直播流
-                               change_room_chan <- true
+                               for len(change_room_chan) != 0 {<-change_room_chan}
+                               change_room_chan <- struct{}{}
                                return false
                        },
                        `c.Rev_add`:func(data interface{})(bool){//收入
@@ -82,6 +83,9 @@ func Demo(roomid ...int) {
                                interrupt <- os.Interrupt
                                return false
                        },
+               })
+               //单独,避免队列执行耗时block从而无法接收更多消息
+               c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
                        `pm`:func(data interface{})(bool){//私信
                                if tmp,ok := data.(send.Pm_item);ok{
                                        send.Send_pm(tmp.Uid,tmp.Msg)
index e37e7e3e572bf2f1e049b3f5cdd173b1d740399c..3f2bcaebb3596a88f057a6ff011f9aa738e45675 100644 (file)
@@ -8,4 +8,5 @@
 |config_disable_msg.json|禁用消息开关|
 |config_gtk_keep_key.json|gtk醒目提示时长|
 |config_tts.json|语音提示模板|
+|config_K_v.json|Key-value键值设置|
 ---
\ No newline at end of file
diff --git a/demo/face/0multi b/demo/face/0multi
new file mode 100644 (file)
index 0000000..d390f51
Binary files /dev/null and b/demo/face/0multi differ
index 8ab02b2439884ac0d744b5ca23f92ab7c8beab4f..b772f717fce72c6b716b9847766b9fbce9a8d799 100644 (file)
@@ -14,4 +14,5 @@
 |0room|房间消息时的头像|
 |0superchat|醒目留言时显示的头像|
 |0tianxuan|天选之人消息时显示的头像|
+|0multi|多人消息时显示的头像|
 ---
\ No newline at end of file
index 95f06be2575de447c0eb751ce0e42d03892da820..fdbbc80141a54d4f43fd13901449c463dfe04851 100644 (file)
@@ -11,7 +11,7 @@ require (
        github.com/miekg/dns v1.1.35 // indirect
        github.com/mitchellh/mapstructure v1.4.0 // indirect
        github.com/qydysky/bili_danmu v0.5.7
-       github.com/qydysky/part v0.3.5-0.20201228170623-c701da7df342 // indirect
+       github.com/qydysky/part v0.3.5-0.20210105160037-508c706d691b // indirect
        github.com/shirou/gopsutil v3.20.12+incompatible // indirect
        github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
        golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect
@@ -22,4 +22,5 @@ require (
 replace (
        github.com/gotk3/gotk3 v0.5.2 => github.com/qydysky/gotk3 v0.0.0-20210103171910-327affdaaa80
        github.com/qydysky/bili_danmu => ../
+//github.com/qydysky/part => ../../part
 )
index 25744247ec9bbed21119d99486005316905ec1ba..8d811f3e3986cdc542111d28d3b44ed4ca544035 100644 (file)
@@ -101,6 +101,8 @@ github.com/qydysky/part v0.3.5-0.20201228153342-9ad523c2bef4 h1:0A7uj8u2PTn2DXea
 github.com/qydysky/part v0.3.5-0.20201228153342-9ad523c2bef4/go.mod h1:SxxNav0Z7DbsDLoG5uxo0wW5EKU/JBu2CAkZzZeLnX0=
 github.com/qydysky/part v0.3.5-0.20201228170623-c701da7df342 h1:7wCI40bHHgJ9+yByTqvLM7Jctz9Z5oMoK2AATHBHxaQ=
 github.com/qydysky/part v0.3.5-0.20201228170623-c701da7df342/go.mod h1:SxxNav0Z7DbsDLoG5uxo0wW5EKU/JBu2CAkZzZeLnX0=
+github.com/qydysky/part v0.3.5-0.20210105160037-508c706d691b h1:rKR4PD/8CzT28Whf4ILQ4WZZW1S8MxJFSluYtrzu5+c=
+github.com/qydysky/part v0.3.5-0.20210105160037-508c706d691b/go.mod h1:SxxNav0Z7DbsDLoG5uxo0wW5EKU/JBu2CAkZzZeLnX0=
 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/qydysky/part/msgq v0.0.0-20201213120821-f36e49c32bba h1:1ew9dRpc0Rux0WkWeT/4AE15ynYWmL2D7onJEJIFOB8=
index f91f0419da96ea70f0ad5495bd3aec53eccae479..cd0204a9721de54375728b9d91f65b139d793b69 100644 (file)
@@ -1,9 +1,17 @@
 package main
 
 import (
+       // "os"
+       // "runtime/pprof"
        q "github.com/qydysky/bili_danmu"
 )
 
 func main() {
+       // f, _ := os.OpenFile("cpu.pprof", os.O_RDWR|os.O_CREATE, 0644)
+    // pprof.StartCPUProfile(f)
+
        q.Demo()
+
+       // pprof.StopCPUProfile()
+    // f.Close()
 }
\ No newline at end of file