feat: 在 MsgInHandler 中添加 Panic 恢复日志记录,并在出现 Panic 时发送警告消息

This commit is contained in:
lixiangwuxian
2025-04-10 01:05:44 +08:00
parent 49be7aafb9
commit 546f1abcd1
2 changed files with 15 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package action
import (
"encoding/json"
"fmt"
"log"
"strconv"
"sync"
"time"
@@ -62,6 +63,7 @@ func (am *actionManager) SendMsg(reply *model.Reply) error {
for !am.Started() {
time.Sleep(100 * time.Millisecond)
}
log.Default().Printf("\033[32m↑\033[0m:%s", string(sendPkgJson))
if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil {
return err
}
@@ -84,6 +86,7 @@ func (am *actionManager) SendForward(reply *model.Reply) error {
if err != nil {
return err
}
log.Default().Printf("\033[32m↑\033[0m:%s", string(sendPkgJson))
if err = am.botConn.WriteMessage(websocket.TextMessage, sendPkgJson); err != nil {
return err
}