diff --git a/bot.go b/bot.go index 8d87215..8829651 100644 --- a/bot.go +++ b/bot.go @@ -228,7 +228,7 @@ func processEventAsync(response []byte, caller APICaller, maxwait time.Duration) // match 匹配规则,处理事件 func match(ctx *Ctx, matchers []*Matcher, maxwait time.Duration) { - if BotConfig.MarkMessage { + if BotConfig.MarkMessage && ctx.Event.MessageID != nil { ctx.MarkThisMessageAsRead() } gorule := func(rule Rule) <-chan bool { diff --git a/driver/wsclient.go b/driver/wsclient.go index eaa3f02..eb2e604 100644 --- a/driver/wsclient.go +++ b/driver/wsclient.go @@ -123,12 +123,13 @@ func (ws *WSClient) Listen(handler func([]byte, zero.APICaller)) { } close(c) // channel only use once } - } else { - if rsp.Get("meta_event_type").Str != "heartbeat" { // 忽略心跳事件 - log.Debug("[ws] 接收到事件: ", helper.BytesToString(payload)) - } - handler(payload, ws) + return + } + if rsp.Get("meta_event_type").Str != "heartbeat" { // 忽略心跳事件 + log.Debug("[ws] 接收到事件: ", helper.BytesToString(payload)) + return } + handler(payload, ws) } } diff --git a/driver/wsserver.go b/driver/wsserver.go index f581107..9be687e 100644 --- a/driver/wsserver.go +++ b/driver/wsserver.go @@ -194,12 +194,13 @@ func (wssc *WSSCaller) listen(handler func([]byte, zero.APICaller)) { } close(c) // channel only use once } - } else { - if rsp.Get("meta_event_type").Str != "heartbeat" { // 忽略心跳事件 - log.Debug("[wss] 接收到事件: ", helper.BytesToString(payload)) - } - handler(payload, wssc) + return + } + if rsp.Get("meta_event_type").Str != "heartbeat" { // 忽略心跳事件 + log.Debug("[wss] 接收到事件: ", helper.BytesToString(payload)) + return } + handler(payload, wssc) } }