diff --git a/adapters/qq/main.go b/adapters/qq/main.go index 564d07f..d837daf 100644 --- a/adapters/qq/main.go +++ b/adapters/qq/main.go @@ -238,6 +238,7 @@ func init() { }() 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() if err != nil { diff --git a/core/adapter.go b/core/adapter.go index eb3fb7b..e7567bc 100644 --- a/core/adapter.go +++ b/core/adapter.go @@ -172,7 +172,8 @@ func (f *Factory) Init(botplt, botid string) { f.demo = &CustomSender{ 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) } Bots[[2]string{botplt, botid}] = f @@ -188,12 +189,9 @@ func (f *Factory) Init(botplt, botid string) { script: plugins.GetString(f.uuid), } str := su.GetValue("message") - if str == "" { - return - } ss := regexp.MustCompile(`\S+`).FindAllString(str, -1) if len(ss) == 0 { - return + ss = []string{f.botplt} } if ss[0] != 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++ if f.errorTimes > 5 { - f.Destroy() + go f.Destroy() } + return f.errorTimes } func (f *Factory) Success() { diff --git a/core/carry.go b/core/carry.go index 4b96b94..d3b7585 100644 --- a/core/carry.go +++ b/core/carry.go @@ -230,6 +230,7 @@ func init() { if ncg.In { if ncg.Enable { AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID)) + AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID)) } else { RemListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)关闭监听模式", ncg.ID)) } @@ -248,6 +249,7 @@ func init() { tmp = append(tmp, ncg) if ncg.In && ncg.Enable { AddListenOnGroup(ncg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", ncg.ID)) + AddNoReplyGroups(ncg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", ncg.ID)) } } else { return nil @@ -271,6 +273,7 @@ func setCgs() { } if cg.In { AddListenOnGroup(cg.ID, fmt.Sprintf("已为采集群(%s)开启监听模式", cg.ID)) + AddNoReplyGroups(cg.ID, fmt.Sprintf("已为采集群(%s)开启禁言模式", cg.ID)) } cgs = append(cgs, cg) return nil