add cases delgamer

This commit is contained in:
vrubelroman 2025-11-16 20:44:02 +03:00
parent 5c69859868
commit 13a83b9fbd
2 changed files with 21 additions and 1 deletions

View file

@ -618,11 +618,29 @@ class LichessBot:
lang = self.db.get_user_language(user_id)
if gamer_to_delete:
username = gamer_to_delete['username']
was_active = gamer_to_delete.get('is_active', False)
total_gamers_before = len(gamers)
deleted = self.db.remove_user_gamer(user_id, gamer_id)
if deleted:
# Check how many gamers remain after deletion
remaining_gamers = self.db.get_user_gamers(user_id)
remaining_count = len(remaining_gamers)
# Determine which message to show
if remaining_count == 0:
# Last gamer deleted
message = t('last_gamer_deleted', lang, username=username)
elif was_active:
# Active gamer deleted but there are other gamers
message = t('active_gamer_deleted', lang, username=username)
else:
# Regular deletion
message = t('gamer_deleted', lang, username=username)
await query.edit_message_text(
t('gamer_deleted', lang, username=username),
message,
parse_mode='HTML'
)
else:

View file

@ -66,6 +66,8 @@ TRANSLATIONS = {
'loading_gamers': "🔄 Loading player list...",
'select_gamer_to_delete': "🗑️ <b>Select player to delete:</b>\n\n",
'gamer_deleted': "✅ Player <b>{username}</b> removed from tracked list.",
'active_gamer_deleted': "✅ Player <b>{username}</b> removed from tracked list.\n\n⚠️ You deleted the active player. Use the /getgamers command to select a player for which the /today, /yesterday, /week commands will work.",
'last_gamer_deleted': "✅ Player <b>{username}</b> removed from tracked list.\n\n⚠️ You deleted the last player. Use the /addgamer command to add a new tracked player.",
'delete_failed': "❌ Failed to delete player",
# Stats commands