debug: add logging to _find_user_id_by_username

To see the actual error when user lookup fails.
This commit is contained in:
shokollm
2026-04-05 02:34:47 +00:00
parent c57b422b6a
commit 7822e65d6c

View File

@@ -775,10 +775,15 @@ async def _find_user_id_by_username(
ctx: ContextTypes.DEFAULT_TYPE, username: str ctx: ContextTypes.DEFAULT_TYPE, username: str
) -> int | None: ) -> int | None:
"""Find user_id by username using Telegram API.""" """Find user_id by username using Telegram API."""
import logging
log = logging.getLogger(__name__)
try: try:
chat = await ctx.bot.get_chat(f"@{username}") chat = await ctx.bot.get_chat(f"@{username}")
log.info(f"Found user {username}: {chat.id}")
return chat.id return chat.id
except Exception: except Exception as e:
log.error(f"Failed to find user @{username}: {e}")
return None return None