From 9e79b9767275bb0c33bf9075f3f7ae3aa39a4b49 Mon Sep 17 00:00:00 2001 From: vrubel Date: Wed, 29 Oct 2025 00:59:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BB=D1=8E=D1=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LichessClientTG_bot/bot.py | 10 +++++++++- LichessClientTG_bot/config.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/LichessClientTG_bot/bot.py b/LichessClientTG_bot/bot.py index 81ab911..1efff98 100644 --- a/LichessClientTG_bot/bot.py +++ b/LichessClientTG_bot/bot.py @@ -205,6 +205,10 @@ class LichessBot: ratings_data = await self.lichess_api.get_user_ratings(username) logger.debug(f"Received ratings for {username}: {ratings_data is not None}") + # Add delay between requests to avoid rate limiting + if i < len(gamers) - 1: # Don't sleep after the last one + await asyncio.sleep(0.5) # 500ms delay between requests + if ratings_data and 'perfs' in ratings_data: perfs = ratings_data['perfs'] bullet_rating = perfs.get('bullet', {}).get('rating', 'N/A') @@ -325,13 +329,17 @@ class LichessBot: text_lines = [] keyboard = [] - for gamer in gamers: + for i, gamer in enumerate(gamers): status = "🟢" if gamer['is_active'] else "⚪" username = gamer['username'] # Get user ratings from Lichess API ratings_data = await self.lichess_api.get_user_ratings(username) + # Add delay between requests to avoid rate limiting + if i < len(gamers) - 1: # Don't sleep after the last one + await asyncio.sleep(0.5) # 500ms delay between requests + if ratings_data and 'perfs' in ratings_data: perfs = ratings_data['perfs'] bullet_rating = perfs.get('bullet', {}).get('rating', 'N/A') diff --git a/LichessClientTG_bot/config.py b/LichessClientTG_bot/config.py index 30e971f..be95831 100644 --- a/LichessClientTG_bot/config.py +++ b/LichessClientTG_bot/config.py @@ -4,7 +4,7 @@ from dotenv import load_dotenv load_dotenv() # Telegram Bot Configuration -TELEGRAM_BOT_TOKEN = "8241474807:AAGcsLiaE9El63ARmUgrWASgkhcBv8QB1c8" +TELEGRAM_BOT_TOKEN = "8241474807:AAH684LTY93aXRou4-LtqU5-p8LuEjzYn8U" # Lichess API Configuration LICHESS_API_BASE_URL = "https://lichess.org/api"