From 3861746a3ea4e311944fa6bd550151c7a532cdfd Mon Sep 17 00:00:00 2001 From: ScuroNeko Date: Wed, 25 Mar 2026 12:56:26 +0300 Subject: [PATCH] logger now initialize before middleware --- handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/handler.go b/handler.go index fe49644..b605482 100644 --- a/handler.go +++ b/handler.go @@ -93,14 +93,14 @@ func (bot *Bot[T]) handleMessage(update *tgapi.Update, ctx *MsgContext) { if _, exists := plugin.commands[cmd]; exists { ctx.Text = args ctx.Args = strings.Fields(args) // Убирает лишние пробелы - if !plugin.executeMiddlewares(ctx, bot.dbContext) { - return - } ctx.Logger = plugin.logger if ctx.Logger == nil { ctx.Logger = bot.logger } + if !plugin.executeMiddlewares(ctx, bot.dbContext) { + return + } plugin.executeCmd(cmd, ctx, bot.dbContext) return } @@ -132,13 +132,13 @@ func (bot *Bot[T]) handleCallback(update *tgapi.Update, ctx *MsgContext) { continue } - if !plugin.executeMiddlewares(ctx, bot.dbContext) { - return - } ctx.Logger = plugin.logger if ctx.Logger == nil { ctx.Logger = bot.logger } + if !plugin.executeMiddlewares(ctx, bot.dbContext) { + return + } plugin.executePayload(data.Command, ctx, bot.dbContext) return }