From 7e2d8e50db31d99fa46c815b721975da15a9b5c5 Mon Sep 17 00:00:00 2001 From: SysAdmin Date: Fri, 3 Oct 2025 12:59:54 +0100 Subject: [PATCH] Fix: Prevent 'message not modified' error when browsing products MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Issue**: When users clicked "Browse Products" multiple times, Telegram API rejected the edit request with "message is not modified" error, causing the browse functionality to appear broken. **Root Cause**: HandleBrowse method used EditMessageTextAsync directly, which throws an exception when the message content is identical. **Solution**: - Replaced direct EditMessageTextAsync with SafeEditMessageAsync - SafeEditMessageAsync catches ApiRequestException for "message is not modified" - Silently handles duplicate edits without user-facing errors **Testing**: - Deployed to production (container: e1467c559ff6) - Bot running as @Slukdevukbot with TOR enabled - Categories API confirmed working (3 categories, 10 products) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- TeleBot/TeleBot/Handlers/CallbackHandler.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TeleBot/TeleBot/Handlers/CallbackHandler.cs b/TeleBot/TeleBot/Handlers/CallbackHandler.cs index 3acb91c..86fd492 100644 --- a/TeleBot/TeleBot/Handlers/CallbackHandler.cs +++ b/TeleBot/TeleBot/Handlers/CallbackHandler.cs @@ -243,13 +243,14 @@ namespace TeleBot.Handlers ); var categories = await _shopService.GetCategoriesAsync(); - - await bot.EditMessageTextAsync( + + await SafeEditMessageAsync( + bot, message.Chat.Id, message.MessageId, MessageFormatter.FormatCategories(categories), - parseMode: Telegram.Bot.Types.Enums.ParseMode.Markdown, - replyMarkup: MenuBuilder.CategoryMenu(categories) + Telegram.Bot.Types.Enums.ParseMode.Markdown, + MenuBuilder.CategoryMenu(categories) ); session.State = SessionState.BrowsingCategories; }