add token bug fix

This commit is contained in:
vrubelroman 2025-11-19 12:02:54 +03:00
parent 1f384c12ab
commit 278c5b9c40
2 changed files with 10 additions and 3 deletions

View file

@ -294,8 +294,11 @@ class LichessBot:
token = update.message.text.strip()
user_id = update.effective_user.id
logger.info(f"Processing token for user {user_id}, token prefix: {token[:10]}...")
# Get username from token
profile = await self.lichess_api.get_user_profile(token)
logger.info(f"Profile response: {profile is not None}")
if profile:
username = profile.get('username')
if username:
@ -1317,6 +1320,7 @@ class LichessBot:
self.application = application # Store application reference
# Conversation handler for addtoken (token required)
# Must be added BEFORE general MessageHandler to avoid conflicts
addtoken_conv = ConversationHandler(
entry_points=[CommandHandler("addtoken", self.addtoken_start)],
states={
@ -1325,11 +1329,11 @@ class LichessBot:
fallbacks=[CommandHandler("cancel", lambda u, c: ConversationHandler.END)]
)
# Add handlers
# Add handlers - ConversationHandler must be before general MessageHandler
application.add_handler(CommandHandler("start", self.start_and_addgamer))
application.add_handler(CommandHandler("addgamer", self.addgamer_start))
application.add_handler(addtoken_conv) # Add before general MessageHandler
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, self.handle_username))
application.add_handler(addtoken_conv)
application.add_handler(CommandHandler("getgamers", self.getgamers))
application.add_handler(CommandHandler("delgamer", self.delgamer))
application.add_handler(CommandHandler("today", self.today))