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:
parent
d07e1ee77a
commit
e694e8b482
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user