Skip to content

Commit

Permalink
新增recover
Browse files Browse the repository at this point in the history
  • Loading branch information
rroy233 committed Jul 8, 2024
1 parent 9af7466 commit a771598
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions router/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/rroy233/StickerDownloader/statistics"
"github.com/rroy233/StickerDownloader/utils"
"gopkg.in/rroy233/logger.v2"
"runtime/debug"
"strings"
"time"
)
Expand All @@ -26,6 +27,14 @@ func Handle(update tgbotapi.Update) {

logger.Info.Println(utils.LogUserInfo(&update) + utils.JsonEncode(update))

//recover
defer func() {
if r := recover(); r != nil {
logger.Error.Printf("[APP CRUSHED]%v %s", r, string(debug.Stack()))
utils.SendPlainText(&update, languages.Get(&update).BotMsg.ErrSysFailureOccurred)
}
}()

//auto leave channel
if update.ChannelPost != nil || update.EditedChannelPost != nil {
handler.AutoLeave(update)
Expand Down

0 comments on commit a771598

Please sign in to comment.