Skip to content

Commit

Permalink
fix: nil mark_as_read
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Jul 28, 2023
1 parent 8d5946e commit a433140
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bot.go
Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions driver/wsclient.go
Expand Up @@ -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)
}
}

Expand Down
11 changes: 6 additions & 5 deletions driver/wsserver.go
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit a433140

Please sign in to comment.