demo/ui/*.glade~
demo/tts.mp3
demo/cpu.pprof
+demo/qr.png
"net/url"
qr "github.com/skip2/go-qrcode"
+ msgq "github.com/qydysky/part/msgq"
c "github.com/qydysky/bili_danmu/CV"
+ web "github.com/qydysky/part/web"
g "github.com/qydysky/part/get"
p "github.com/qydysky/part"
uuid "github.com/gofrs/uuid"
apilog.L(`E: `,e)
return
}
- res := string(r.Respon)
- if v,ok := p.Json().GetValFromS(res, "status").(bool);!ok || !v {
- apilog.L(`E: `,`getLoginUrl status failed!`)
+ var res struct{
+ Code int `json:"code"`
+ Status bool `json:"status"`
+ Data struct{
+ Url string `json:"url"`
+ OauthKey string `json:"oauthKey"`
+ } `json:"data"`
+ }
+ if e := json.Unmarshal(r.Respon, &res);e != nil {
+ apilog.L(`E: `, e)
return
- } else {
- if v,ok := p.Json().GetValFromS(res, "data.url").(string);ok {
- img_url = v
- }
- if v,ok := p.Json().GetValFromS(res, "data.oauthKey").(string);ok {
- oauth = v
- }
}
- if img_url == `` || oauth == `` {
- apilog.L(`E: `,`img_url:`,img_url,` oauth:`,oauth)
+ if res.Code != 0 {
+ apilog.L(`E: `, `code != 0`)
return
}
+ if !res.Status {
+ apilog.L(`E: `, `status == false`)
+ return
+ }
+
+ if res.Data.Url == `` {
+ apilog.L(`E: `, `Data.Urls == ""`)
+ return
+ } else {img_url = res.Data.Url}
+ if res.Data.OauthKey == `` {
+ apilog.L(`E: `, `Data.OauthKey == ""`)
+ return
+ } else {oauth = res.Data.OauthKey}
}
- var server *http.Server
+ var server = new(http.Server)
{//生成二维码
qr.WriteFile(img_url,qr.Medium,256,`qr.png`)
if !p.Checkfile().IsExist(`qr.png`) {
apilog.L(`E: `,`qr error`)
return
}
- go func(){//启动web
- web := http.NewServeMux()
- web.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域
- w.Header().Add("Access-Control-Allow-Headers", "Content-Type") //header的类型
+ //启动web
+ s := web.New(server)
+ s.Handle(map[string]func(http.ResponseWriter,*http.Request){
+ `/`:func(w http.ResponseWriter,r *http.Request){
var path string = r.URL.Path[1:]
- http.ServeFile(w, r,`./`+path)
- })
- server = &http.Server{
- Addr: `127.0.0.1:`+strconv.Itoa(p.Sys().GetFreePort()),
- WriteTimeout: time.Second * 10,
- Handler: web,
- }
- apilog.L(`W: `,`打开链接扫码登录:`,`http://`+server.Addr+`/qr.png`)
- server.ListenAndServe()
- }()
+ if path == `` {path = `index.html`}
+ http.ServeFile(w, r, path)
+ },
+ `/exit`:func(w http.ResponseWriter,r *http.Request){
+ s.Server.Shutdown(context.Background())
+ },
+ })
+ apilog.L(`W: `,`打开链接扫码登录:`,`http://`+server.Addr+`/qr.png`)
p.Sys().Timeoutf(1)
}
var cookie string
{//3s刷新查看是否通过
max_try := 20
change_room_sign := false
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`change_room`:func(data interface{})(bool){//房间改变
change_room_sign = true
return true
PostStr += `csrf_token=`+csrf+`&csrf=`+csrf+`&`
PostStr += `visit_id=`
- if wasm := Wasm(0, rt_obj);wasm == `` {//0全局
+ if wasm := Wasm(3, 0, rt_obj);wasm == `` {//0全局
apilog.L(`E: `,`发生错误`)
return
} else {
"time"
"github.com/skratchdot/open-golang/open"
websocket "github.com/qydysky/part/websocket"
+ msgq "github.com/qydysky/part/msgq"
web "github.com/qydysky/part/web"
c "github.com/qydysky/bili_danmu/CV"
)
//全局对象
var (
wslog = c.Log.Base(`api`).Base_add(`小心心加密`) //日志
- rec_chan = make(chan S)//收通道
+ rec_chan = make(chan S,5)//收通道
webpath string//web地址,由于实时获取空闲端口,故将在稍后web启动后赋值
ws = websocket.New_server()//新建websocket实例
)
func server() {
{
ws_mq := ws.Interface()//获取websocket操作对象
- ws_mq.Pull_tag(map[string]func(interface{})(bool){
+ ws_mq.Pull_tag(msgq.FuncMap{
`recv`:func(data interface{})(bool){
if tmp,ok := data.(websocket.Uinterface);ok {//websocket接收并响应
//websocket.Uinterface{
wslog.L(`E: `, e, string(tmp.Data))
}
- select{//无多用户上传不同数据的情况,仅接收1个,其余会因通道无传出而忽略
+ select{
case rec_chan <- s:
default:
}
wslog.L(`I: `,`如需加密,会自动打开`,webpath)
}
-func Wasm(uid uintptr,s RT) (o string) {
+func Wasm(maxloop int, uid uintptr,s RT) (o string) {//maxloop 超时重试
+ if maxloop <= 0 {return}
+
for try:=5;try > 0 && ws.Len() == 0;try-=1 {//没有从池中取出
open.Run(webpath)
wslog.L(`I: `,`浏览器打开`,webpath)
case r :=<- rec_chan:
if r.Id != s.R.Id {break}//或许接收到之前的请求,校验Id字段
return r.S
- case <- time.After(time.Second):
+ case <- time.After(time.Second*time.Duration(3)):
wslog.L(`E: `,`超时!响应>1s,确认保持`,webpath,`开启`)
+ o = Wasm(maxloop-1, uid, s)
return
}
}
func test(uid uintptr) bool {
time.Sleep(time.Second*time.Duration(3))
- if s := Wasm(uid, RT{
+ if s := Wasm(3, uid, RT{
R:R{
Id: "[9,371,1,22613059]",
Device: "[\"AUTO8216117272375373\",\"77bee604-b591-4664-845b-b69603f8c71c\"]",
c "github.com/qydysky/bili_danmu/CV"
F "github.com/qydysky/bili_danmu/F"
+ send "github.com/qydysky/bili_danmu/Send"
"github.com/christopher-dG/go-obs-websocket"
p "github.com/qydysky/part"
+ msgq "github.com/qydysky/part/msgq"
b "github.com/qydysky/part/buf"
s "github.com/qydysky/part/signal"
)
//保存所有消息到json
func init(){
Save_to_json(0, []interface{}{`[`})
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`change_room`:func(data interface{})(bool){//房间改变
Save_to_json(0, []interface{}{`[`})
return false
Context:Context,
})
}
+}
+
+//进入房间发送弹幕
+func Entry_danmu(){
+ if s,ok := c.K_v[`进入房间发送弹幕`].(string);ok && s != ``{
+ send.Danmu_s(s,p.Map_2_Cookies_String(c.Cookie),c.Roomid)
+ }
}
\ No newline at end of file
"github.com/gotk3/gotk3/gtk"
"github.com/gotk3/gotk3/gdk"
p "github.com/qydysky/part"
+ msgq "github.com/qydysky/part/msgq"
F "github.com/qydysky/bili_danmu/F"
c "github.com/qydysky/bili_danmu/CV"
s "github.com/qydysky/part/buf"
if!IsOn("Gtk") {return}
go Gtk_danmu()
//使用带tag的消息队列在功能间传递消息
- Danmu_mq.Pull_tag(map[string]func(interface{})(bool){
+ Danmu_mq.Pull_tag(msgq.FuncMap{
`danmu`:func(data interface{})(bool){//弹幕
select{
case Gtk_danmu_chan <- data.(Danmu_mq_t):
"strings"
p "github.com/qydysky/part"
c "github.com/qydysky/bili_danmu/CV"
+ msgq "github.com/qydysky/part/msgq"
s "github.com/qydysky/part/buf"
)
//消息队列接收tts类消息,并传送到TTS朗读
//使用带tag的消息队列在功能间传递消息
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`tts`:func(data interface{})(bool){//tts
if _,ok := tts_setting[data.(Danmu_mq_t).uid];ok {
tts_List <- data
p "github.com/qydysky/part"
ws "github.com/qydysky/part/websocket"
g "github.com/qydysky/part/get"
+ msgq "github.com/qydysky/part/msgq"
reply "github.com/qydysky/bili_danmu/Reply"
send "github.com/qydysky/bili_danmu/Send"
c "github.com/qydysky/bili_danmu/CV"
}()
//使用带tag的消息队列在功能间传递消息
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`change_room`:func(data interface{})(bool){//房间改变
c.Rev = 0.0 //营收
c.Renqi = 1//人气置1
},
})
//单独,避免队列执行耗时block从而无法接收更多消息
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`pm`:func(data interface{})(bool){//私信
if tmp,ok := data.(send.Pm_item);ok{
send.Send_pm(tmp.Uid,tmp.Msg)
//订阅消息,以便刷新舰长数
api.Get_guardNum()
//使用带tag的消息队列在功能间传递消息
- c.Danmu_Main_mq.Pull_tag(map[string]func(interface{})(bool){
+ c.Danmu_Main_mq.Pull_tag(msgq.FuncMap{
`guard_update`:func(data interface{})(bool){//舰长更新
go api.Get_guardNum()
return false
go api.F_x25Kn()
//每日签到
F.Dosign()
+ //附加功能 每日发送弹幕
+ go reply.Entry_danmu()
return false
},
})
if len(c.Cookie) != 0 {//附加功能 弹幕机 无cookie无法发送弹幕
reply.Danmuji_auto(1)
}
- {//附加功能 直播流保存 营收
+ {//附加功能 进房间发送弹幕 直播流保存 营收
+ go reply.Entry_danmu()
go reply.Saveflvf()
go reply.ShowRevf()
}
"save_to_json":"",
"get_xiao_xinxin-help":"获取小心心",
- "get_xiao_xinxin":true
+ "get_xiao_xinxin":true,
+
+ "进入房间发送弹幕":" "
}
\ No newline at end of file
github.com/miekg/dns v1.1.38 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/qydysky/bili_danmu v0.5.7
- github.com/qydysky/part v0.3.13 // indirect
+ github.com/qydysky/part v0.3.15 // indirect
github.com/shirou/gopsutil v3.21.1+incompatible // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/qydysky/part v0.3.12/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
github.com/qydysky/part v0.3.13 h1:GN5SvmdcGwGbzP+N7cgxEgIzL2CdSSFoMXGbPIfM9os=
github.com/qydysky/part v0.3.13/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
+github.com/qydysky/part v0.3.14 h1:A73pP/LqScwOuh9eEAaOb1y+CFLPr4A4eev+8Jv5Q9o=
+github.com/qydysky/part v0.3.14/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
+github.com/qydysky/part v0.3.15 h1:dRdGUfMk3XMR88jE0xx54FoKwsz6e5Vh4gSFuY7oxpc=
+github.com/qydysky/part v0.3.15/go.mod h1:43opuciW71sZvOR67kye50jgMDSDrn/t6+LefNdlXPg=
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=