fix silent onboarding drop-off in /addgamer flow
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 33s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 33s
Set awaiting_addgamer_username as soon as the menu is shown so typing a username directly (without tapping the button) is handled instead of being silently ignored. Also stop reporting a valid username as "not found" when Lichess returns a non-404 error (rate limit/timeout), and surface an error message if the addgamer menu itself fails to send.
This commit is contained in:
parent
e9516f8664
commit
2a7385290e
3 changed files with 32 additions and 4 deletions
|
|
@ -145,8 +145,15 @@ class LichessAPI:
|
|||
logger.error(f"Error getting puzzles period: {e}")
|
||||
return None
|
||||
|
||||
async def check_user_exists(self, username: str) -> bool:
|
||||
"""Check if user exists on Lichess"""
|
||||
async def check_user_exists(self, username: str) -> Optional[bool]:
|
||||
"""
|
||||
Check if user exists on Lichess.
|
||||
|
||||
Returns True/False for a definitive answer (200/404), or None if the
|
||||
check itself failed (rate limit, network error, unexpected status) —
|
||||
callers must not treat None as "not found", since the username may
|
||||
well be valid.
|
||||
"""
|
||||
await self.rate_limiter.wait_if_needed()
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
|
|
@ -160,10 +167,10 @@ class LichessAPI:
|
|||
return False
|
||||
else:
|
||||
logger.error(f"Failed to check user existence: {response.status}")
|
||||
return False
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.error(f"Error checking user existence: {e}")
|
||||
return False
|
||||
return None
|
||||
|
||||
async def get_user_ratings(self, username: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get user ratings from Lichess API"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue