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
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user