fix silent onboarding drop-off in /addgamer flow
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:
vrubelroman 2026-07-03 12:23:40 +00:00
parent e9516f8664
commit 2a7385290e
3 changed files with 32 additions and 4 deletions

View file

@ -340,6 +340,11 @@ class LichessBot:
logger.info(f"addgamer_start called for user {user_id}")
lang = self.get_user_language_from_update(update)
# Mark that we're awaiting a username right away: the menu below is shown
# so a user typing the name directly (without tapping a button) is handled
# too, instead of being silently ignored by handle_username.
if context and hasattr(context, "user_data"):
context.user_data['awaiting_addgamer_username'] = True
try:
keyboard = [
[
@ -365,6 +370,10 @@ class LichessBot:
logger.error(f"Error sending addgamer menu: {e}")
import traceback
logger.error(traceback.format_exc())
try:
await update.message.reply_text(t('addgamer_menu_error', lang))
except Exception as e2:
logger.error(f"Failed to send addgamer menu error message: {e2}")
# No conversation state returned; handler-based flow
return
@ -603,6 +612,14 @@ class LichessBot:
# Check if user exists on Lichess
user_exists = await self.lichess_api.check_user_exists(username)
if user_exists is None:
# Transient API failure (rate limit, network error, unexpected status) —
# don't tell the user the name is wrong, it may well be valid.
await update.message.reply_text(
t('lichess_temporarily_unavailable', lang) + '\n\n' + t('addgamer_prompt', lang),
parse_mode='HTML'
)
return
if not user_exists:
await update.message.reply_text(
t('user_not_found', lang, username=username) + '\n\n' + t('addgamer_prompt', lang),