This commit is contained in:
cdle
2023-06-09 13:38:02 +08:00
parent e2aa34653c
commit 10d5400f2f
3 changed files with 10 additions and 7 deletions
+1
View File
@@ -238,6 +238,7 @@ func init() {
}() }()
for { for {
//{"self_id":"17745270","status":{"online":true,"good":false},"time":1686281911,"post_type":"meta_event","meta_event_type":"heartbeat","interval":3000}
_, data, err := ws.ReadMessage() _, data, err := ws.ReadMessage()
if err != nil { if err != nil {
+6 -7
View File
@@ -172,7 +172,8 @@ func (f *Factory) Init(botplt, botid string) {
f.demo = &CustomSender{ f.demo = &CustomSender{
f: f, f: f,
} }
if _, ok := Bots[[2]string{botplt, botid}]; ok { if v, ok := Bots[[2]string{botplt, botid}]; ok {
v.Destroy()
console.Warn("%s机器人%s因冲突销毁!", botplt, botid) console.Warn("%s机器人%s因冲突销毁!", botplt, botid)
} }
Bots[[2]string{botplt, botid}] = f Bots[[2]string{botplt, botid}] = f
@@ -188,12 +189,9 @@ func (f *Factory) Init(botplt, botid string) {
script: plugins.GetString(f.uuid), script: plugins.GetString(f.uuid),
} }
str := su.GetValue("message") str := su.GetValue("message")
if str == "" {
return
}
ss := regexp.MustCompile(`\S+`).FindAllString(str, -1) ss := regexp.MustCompile(`\S+`).FindAllString(str, -1)
if len(ss) == 0 { if len(ss) == 0 {
return ss = []string{f.botplt}
} }
if ss[0] != f.botplt { if ss[0] != f.botplt {
ss = []string{f.botplt} ss = []string{f.botplt}
@@ -208,11 +206,12 @@ func (f *Factory) Init(botplt, botid string) {
}() }()
} }
func (f *Factory) Fail() { func (f *Factory) Fail() int {
f.errorTimes++ f.errorTimes++
if f.errorTimes > 5 { if f.errorTimes > 5 {
f.Destroy() go f.Destroy()
} }
return f.errorTimes
} }
func (f *Factory) Success() { func (f *Factory) Success() {
+3
View File
@@ -230,6 +230,7 @@ func init() {
if ncg.In { if ncg.In {
if ncg.Enable { if ncg.Enable {
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID)) AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID))
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID))
} else { } else {
RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", ncg.ID)) RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", ncg.ID))
} }
@@ -248,6 +249,7 @@ func init() {
tmp = append(tmp, ncg) tmp = append(tmp, ncg)
if ncg.In && ncg.Enable { if ncg.In && ncg.Enable {
AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID)) AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID))
AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID))
} }
} else { } else {
return nil return nil
@@ -271,6 +273,7 @@ func setCgs() {
} }
if cg.In { if cg.In {
AddListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", cg.ID)) AddListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", cg.ID))
AddNoReplyGroups(cg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", cg.ID))
} }
cgs = append(cgs, cg) cgs = append(cgs, cg)
return nil return nil