v1.0.0 beta 18

This commit is contained in:
2026-03-13 11:24:13 +03:00
parent e4203e8fc0
commit 6ba8520bb7
9 changed files with 101 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"strings"
"git.nix13.pw/scuroneko/laniakea/tgapi"
@@ -12,6 +13,12 @@ import (
var ErrInvalidPayloadType = errors.New("invalid payload type")
func (bot *Bot[T]) handle(u *tgapi.Update) {
defer func() {
if r := recover(); r != nil {
bot.logger.Errorln(fmt.Sprintf("panic in handle: %v", r))
}
}()
ctx := &MsgContext{
Update: *u, Api: bot.api,
botLogger: bot.logger,
@@ -84,7 +91,7 @@ func (bot *Bot[T]) handleMessage(update *tgapi.Update, ctx *MsgContext) {
if !plugin.executeMiddlewares(ctx, bot.dbContext) {
return
}
go plugin.executeCmd(cmd, ctx, bot.dbContext)
plugin.executeCmd(cmd, ctx, bot.dbContext)
return
}
}
@@ -113,7 +120,7 @@ func (bot *Bot[T]) handleCallback(update *tgapi.Update, ctx *MsgContext) {
if !plugin.executeMiddlewares(ctx, bot.dbContext) {
return
}
go plugin.executePayload(data.Command, ctx, bot.dbContext)
plugin.executePayload(data.Command, ctx, bot.dbContext)
return
}
}