}
type Autoskip struct {
+ roomid int
buf map[string]Autoskip_item
sync.Mutex
now uint
if len(autoskip.buf) == 0 {continue}
autoskip.now += 1
autoskip.Lock()
+ if autoskip.roomid != c.Roomid {
+ autoskip.buf = make(map[string]Autoskip_item)
+ autoskip.roomid = c.Roomid
+ flog.Base_add(`弹幕合并`).L(`T: `,`房间更新:`,autoskip.roomid)
+ autoskip.Unlock()
+ continue
+ }
for k,v := range autoskip.buf{
if v.Exprie <= autoskip.now {
delete(autoskip.buf,k)
{//超时显示
if v.Num > 3 {
- Msg_showdanmu(nil, strconv.Itoa(int(v.Num)) + " x " + k,`0multi`)
+ Msg_showdanmu(Danmu_item{
+ msg:strconv.Itoa(int(v.Num)) + " x " + k,
+ uid:`0multi`,
+ roomid:autoskip.roomid,
+ })
} else if v.Num > 1 {
- Msg_showdanmu(nil, strconv.Itoa(int(v.Num)) + " x " + k,`0default`)
+ Msg_showdanmu(Danmu_item{
+ msg:strconv.Itoa(int(v.Num)) + " x " + k,
+ uid:`0default`,
+ roomid:autoskip.roomid,
+ })
}
}
}
if !IsOn("弹幕合并") || s == ""{return 0}
autoskip.Lock()
defer autoskip.Unlock()
+ if autoskip.roomid != c.Roomid {
+ autoskip.buf = make(map[string]Autoskip_item)
+ autoskip.roomid = c.Roomid
+ flog.Base_add(`弹幕合并`).L(`T: `,`房间更新:`,autoskip.roomid)
+ return 0
+ }
{//验证是否已经存在
if v,ok := autoskip.buf[s];ok && autoskip.now < v.Exprie{
autoskip.buf[s] = Autoskip_item{
}
type Lessdanmu struct {
+ roomid int
buf []string
limit *limit.Limit
max_num int
time.Sleep(time.Second*10)
lessdanmu.Lock()
+ if lessdanmu.roomid != c.Roomid {
+ lessdanmu.buf = nil
+ lessdanmu.roomid = c.Roomid
+ lessdanmu.threshold = 0.7
+ flog.Base_add(`更少弹幕`).L(`T: `,`房间更新:`,lessdanmu.roomid)
+ lessdanmu.Unlock()
+ continue
+ }
if ptk := lessdanmu.limit.PTK();ptk == lessdanmu.max_num {
if lessdanmu.threshold > 0.03 {
lessdanmu.threshold -= 0.03
func Lessdanmuf(s string) (show bool) {
if !IsOn("相似弹幕忽略") {return true}
+ if lessdanmu.roomid != c.Roomid {
+ lessdanmu.Lock()
+ lessdanmu.buf = nil
+ lessdanmu.roomid = c.Roomid
+ lessdanmu.threshold = 0.7
+ lessdanmu.Unlock()
+ flog.Base_add(`更少弹幕`).L(`T: `,`房间更新:`,lessdanmu.roomid)
+ return true
+ }
if len(lessdanmu.buf) < 20 {
lessdanmu.buf = append(lessdanmu.buf, s)
return true
}
//Msg-弹幕处理
+type Danmu_item struct {
+ msg string
+ auth interface{}
+ uid string
+ roomid int//to avoid danmu show when room has changed
+}
func (replyF) danmu(s string) {
var j struct {
Cmd string `json:"cmd"`
}
infob := j.Info
- msg := infob[1].(string)
- auth := infob[2].([]interface{})[1]
- uid := strconv.Itoa(int(infob[2].([]interface{})[0].(float64)))
- // timeStramp := int64(infob[0].([]interface{})[4].(float64))
+ item := Danmu_item{}
+ {
+ //解析
+ if len(infob) > 0 {
+ item.msg,_ = infob[1].(string)
+ }
+ if len(infob) > 1 {
+ i,_ := infob[2].([]interface{})
+ if len(i) > 0 {
+ item.uid = strconv.Itoa(int(i[0].(float64)))
+ }
+ if len(i) > 1 {
+ item.auth = i[1]
+ }
+ }
+ item.roomid = c.Roomid
+ }
msglog := msglog.Log_show_control(false)
{//附加功能 弹幕机 封禁 弹幕合并
- Danmujif(msg)
- if Autobanf(msg) {
- Gui_show(Itos([]interface{}{"风险", auth, ":", msg}))
- fmt.Println("风险", auth, ":", msg)
- msglog.Base_add("风险").L(`I: `, auth, ":", msg)
+ go Danmujif(item.msg)
+ if Autobanf(item.msg) {
+ Gui_show(Itos([]interface{}{"风险", item.auth, ":", item.msg}))
+ fmt.Println("风险", item.auth, ":", item.msg)
+ msglog.Base_add("风险").L(`I: `, item.auth, ":", item.msg)
return
}
- if i := Autoskipf(msg); i > 0 {
- msglog.L(`I: `, auth, ":", msg)
+ if i := Autoskipf(item.msg); i > 0 {
+ msglog.L(`I: `, item.auth, ":", item.msg)
return
}
}
- Msg_showdanmu(auth, msg, uid)
+ Msg_showdanmu(item)
}
//弹幕发送
//弹幕显示
//由于额外功能有些需要显示,为了统一管理,使用此方法进行处理
-func Msg_showdanmu(auth interface{}, m ...string) {
- msg := m[0]
+func Msg_showdanmu(item Danmu_item) {
+ msg := item.msg
msglog := msglog.Log_show_control(false)
{//附加功能 更少弹幕
if !Lessdanmuf(msg) {
- if auth != nil {msglog.L(`I: `, auth, ":", msg)}
+ if item.auth != nil {msglog.L(`I: `, item.auth, ":", msg)}
return
}
if _msg := Shortdanmuf(msg); _msg == "" {
- if auth != nil {msglog.L(`I: `, auth, ":", msg)}
+ if item.auth != nil {msglog.L(`I: `, item.auth, ":", msg)}
return
} else {msg = _msg}
+ }
+
+ //room change
+ if item.roomid != 0 && item.roomid != c.Roomid {return}
+
+ //展示
+ {
Assf(msg)//ass
- if auth != nil {
- Gui_show(fmt.Sprint(auth) +`: `+ msg, m[1])
+ if item.auth != nil {
+ Gui_show(fmt.Sprint(item.auth) +`: `+ msg, item.uid)
} else {
- Gui_show(m...)
- }
+ Gui_show(msg, item.uid)
+ }
}
{//语言tts 私信
- if len(m) > 1 {
+ if item.uid != "" {
c.Danmu_Main_mq.Push_tag(`tts`,Danmu_mq_t{//传入消息队列
- uid:m[1],
+ uid:item.uid,
msg:msg,
})
- if i,e := strconv.Atoi(m[1]);e == nil {
+ if i,e := strconv.Atoi(item.uid);e == nil {
c.Danmu_Main_mq.Push_tag(`pm`,send.Pm_item{
Uid:i,
Msg:c.K_v.LoadV(`弹幕私信`).(string),
}
}
fmt.Println(msg)
- if auth != nil {msglog.L(`I: `, auth, ":", msg)}
+ if item.auth != nil {msglog.L(`I: `, item.auth, ":", msg)}
}
type Danmu_mq_t struct {