diff --git a/botspot/components/features/user_interactions.py b/botspot/components/features/user_interactions.py index 419616a..7c6fa68 100644 --- a/botspot/components/features/user_interactions.py +++ b/botspot/components/features/user_interactions.py @@ -3,6 +3,7 @@ from typing import Dict, List, Optional, Union from aiogram import Bot, F, types +from aiogram.exceptions import TelegramBadRequest from aiogram.fsm.context import FSMContext from aiogram.fsm.state import State, StatesGroup from aiogram.types import InaccessibleMessage, InlineKeyboardButton, InlineKeyboardMarkup, Message @@ -444,6 +445,12 @@ async def handle_choice_callback(callback_query: types.CallbackQuery, state: FSM new_text = f"{callback_query.message.text}\n\nSelected: {choice}" try: await callback_query.message.edit_text(new_text) + except TelegramBadRequest as e: + if "message to edit not found" in e.message: + # This can happen if the message was deleted or edited by another process + logger.debug("Message was cleaned up, skipping edit") + else: + logger.warning(f"Failed to edit message after choice selection: {e}") except Exception as e: logger.warning(f"Failed to edit message after choice selection: {e}") diff --git a/botspot/components/new/queue_manager.py b/botspot/components/new/queue_manager.py index 2f87db9..11b7457 100644 --- a/botspot/components/new/queue_manager.py +++ b/botspot/components/new/queue_manager.py @@ -88,8 +88,8 @@ async def add_item(self, item: T, user_id: Optional[int] = None): raise QueuePermissionError("user_id is required unless single_user_mode is enabled") - # Todo: do I need the mode="json" here? - doc = item.model_dump(by_alias=True, exclude_none=True) + # Use mode="json" to serialize enums and other non-BSON types correctly + doc = item.model_dump(by_alias=True, exclude_none=True, mode="json") logger.debug(f"Item before enrichment: {doc}") mongo_doc = self.enrich_doc(doc, user_id) diff --git a/pyproject.toml b/pyproject.toml index 6aad166..8088ef7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "botspot" -version = "0.10.28" +version = "0.10.30" description = "" readme = "README.md" authors = [