Fix: Prevent 'message not modified' error when browsing products

**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 <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-10-03 12:59:54 +01:00
parent 5a834dcbf8
commit 7e2d8e50db

View File

@ -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;
}