messages when doing questions

This commit is contained in:
vrubelroman 2025-11-16 23:10:08 +03:00
parent 033a0db12f
commit c39bb33282
6 changed files with 132 additions and 25 deletions

View file

@ -662,11 +662,24 @@ class LichessBot:
)
return
# Send initial message about processing
try:
await update.message.reply_text(t('stats_processing', lang), parse_mode='HTML')
except Exception:
pass
# Process each gamer
has_any_activity = False
for i, gamer in enumerate(gamers):
username = gamer['username']
# Send message about processing this player
processing_msg = None
try:
processing_msg = await update.message.reply_text(t('stats_player_processing', lang, username=username), parse_mode='HTML')
except Exception:
pass
# Get stats based on period
if period == "today":
data = await self.lichess_api.get_today_stats(username)
@ -678,6 +691,13 @@ class LichessBot:
await update.message.reply_text(t('unknown_period', lang))
return
# Delete processing message
if processing_msg:
try:
await processing_msg.delete()
except Exception:
pass
# Check if there's activity
has_activity = False
if data and data.get('data'):
@ -704,11 +724,14 @@ class LichessBot:
# Add delay between requests to avoid rate limiting
if i < len(gamers) - 1:
await asyncio.sleep(3.0)
await asyncio.sleep(1.0)
# If no activity for any player
if not has_any_activity:
await update.message.reply_text(t('no_activity', lang))
else:
# Send final message that all is done
await update.message.reply_text(t('stats_all_done', lang))
# Increment counter for the period command
if period == "today":
@ -769,14 +792,22 @@ class LichessBot:
try:
# Send message about processing this player
processing_msg = None
try:
await update.message.reply_text(t('last_year_1000_player_processing', lang, username=username), parse_mode='HTML')
processing_msg = await update.message.reply_text(t('last_year_1000_player_processing', lang, username=username), parse_mode='HTML')
except Exception:
pass
# Get data for this player
data = await self.lichess_api.get_games_period(username, since_ms, now_ms, rated_only=True)
# Delete processing message
if processing_msg:
try:
await processing_msg.delete()
except Exception:
pass
if data:
# Check if there's activity (games_count > 0)
games_count = data.get('games_count', 0)
@ -797,6 +828,9 @@ class LichessBot:
# If no activity for any player
if not has_any_activity:
await update.message.reply_text(t('no_activity', lang))
else:
# Send final message that all is done
await update.message.reply_text(t('stats_all_done', lang))
self.counters.increment('last_year_1000')

View file

@ -49,7 +49,7 @@ DATABASE_PATH = _resolve_database_path()
PERIOD_OPTIONS = [0, 15, 30, 60, 120, 180, 360, 720, 1440] # minutes (0=disable, then: 15min, 30min, 1h, 2h, 3h, 6h, 12h, 24h)
# Bot Version
BOT_VERSION = "1.1.0"
BOT_VERSION = "1.1.1"
# Telegram Bot Long Polling Configuration
POLL_INTERVAL = 1.0 # seconds

View file

@ -99,6 +99,11 @@ TRANSLATIONS = {
'last_year_1000_processing': "⏳ Processing request... This may take a while as requests are very slow.",
'last_year_1000_player_processing': "🔄 Requesting data for player <b>{username}</b>...",
# Stats commands (today/yesterday/week)
'stats_processing': "⏳ Processing request...",
'stats_player_processing': "🔄 Requesting data for player <b>{username}</b>...",
'stats_all_done': "✅ That's all",
# Support
'support_message': (
"💬 <b>Support & Feedback</b>\n\n"