From ab03728d00b47f3b1adff09c03bc59c2b34cc569 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 21 Nov 2025 23:49:26 +0300 Subject: [PATCH] bug fix /addtoken --- LichessClientTG_bot/bot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/LichessClientTG_bot/bot.py b/LichessClientTG_bot/bot.py index 7632812..493fc9f 100644 --- a/LichessClientTG_bot/bot.py +++ b/LichessClientTG_bot/bot.py @@ -296,6 +296,10 @@ class LichessBot: async def addtoken_start(self, update: Update, context: ContextTypes.DEFAULT_TYPE): """Start addtoken command - token required""" + # Reset any existing conversation state + if context and hasattr(context, "user_data"): + context.user_data.clear() + lang = self.get_user_language_from_update(update) await update.message.reply_text(t('addtoken_prompt', lang)) self.counters.increment('addtoken') @@ -1461,7 +1465,12 @@ class LichessBot: states={ WAITING_FOR_TOKEN: [MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_token)], }, - fallbacks=[CommandHandler("cancel", lambda u, c: ConversationHandler.END)] + fallbacks=[ + CommandHandler("cancel", lambda u, c: ConversationHandler.END), + CommandHandler("addtoken", self.addtoken_start) # Allow restarting conversation + ], + per_chat=True, + per_user=True ) # Add handlers - ConversationHandler must be before general MessageHandler