debug: add logging to _find_user_id_by_username
To see the actual error when user lookup fails.
This commit is contained in:
@@ -775,10 +775,15 @@ async def _find_user_id_by_username(
|
||||
ctx: ContextTypes.DEFAULT_TYPE, username: str
|
||||
) -> int | None:
|
||||
"""Find user_id by username using Telegram API."""
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
try:
|
||||
chat = await ctx.bot.get_chat(f"@{username}")
|
||||
log.info(f"Found user {username}: {chat.id}")
|
||||
return chat.id
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
log.error(f"Failed to find user @{username}: {e}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user