1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-05 03:23:49 +08:00

support event recover.

This commit is contained in:
Mrs4s 2020-12-09 14:24:39 +08:00
parent d07e1ee77a
commit e694e8b482

View File

@ -6,6 +6,7 @@ import (
"fmt"
"hash/crc32"
"path"
"runtime/debug"
"sync"
"time"
@ -397,6 +398,11 @@ func (bot *CQBot) dispatchEventMessage(m MSG) {
}
for _, f := range bot.events {
go func(fn func(MSG)) {
defer func() {
if pan := recover(); pan != nil {
log.Warnf("处理事件 %v 时出现错误: %v \n%s", m, pan, debug.Stack())
}
}()
start := time.Now()
fn(m)
end := time.Now()