31 lines
710 B
Go
31 lines
710 B
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"runtime/debug"
|
|
"time"
|
|
|
|
"git.lxtend.com/lixiangwuxian/qqbot/action"
|
|
"git.lxtend.com/lixiangwuxian/qqbot/config"
|
|
"git.lxtend.com/lixiangwuxian/qqbot/model"
|
|
)
|
|
|
|
func ReportPanicToDev() {
|
|
if r := recover(); r != nil {
|
|
stack := debug.Stack()
|
|
errMsg := fmt.Sprintf("[%s] Panic recovered:\nError: %v\nStack Trace:\n%s\n",
|
|
time.Now().Format("2006-01-02 15:04:05"), r, stack)
|
|
log.Print(errMsg)
|
|
action.ActionManager.SendMsg(&model.Reply{
|
|
ReplyMsg: "出现了Panic:\n" + errMsg,
|
|
ReferOriginMsg: false,
|
|
FromMsg: model.Message{
|
|
GroupInfo: model.GroupInfo{
|
|
GroupId: config.ConfigManager.GetConfig().Management.ReportGroup,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
}
|