Skip to content

Commit 70bc417

Browse files
authored
fix: skip random challenge when no bot is found (#1210)
Return immediately when matchmaking cannot pick an opponent, avoiding the misleading 'Will challenge None' log line. Validation: python3 -m py_compile lichess-bot/lib/matchmaking.py
1 parent 3599e62 commit 70bc417

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/matchmaking.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,14 @@ def challenge(self, active_games: set[str], challenge_queue: MULTIPROCESSING_LIS
237237
logger.info("Challenging a random bot")
238238
self.update_user_profile()
239239
bot_username, base_time, increment, days, variant, mode = self.choose_opponent()
240+
if not bot_username:
241+
logger.info("No challenge will be created.")
242+
self.challenge_id = ""
243+
self.rate_limit_timer = Timer(seconds(60))
244+
return
245+
240246
logger.info(f"Will challenge {bot_username} for a {variant} game.")
241-
challenge_id = self.create_challenge(bot_username, base_time, increment, days, variant, mode) if bot_username else ""
247+
challenge_id = self.create_challenge(bot_username, base_time, increment, days, variant, mode)
242248
logger.info(f"Challenge id is {challenge_id or 'None'}.")
243249
self.challenge_id = challenge_id
244250

0 commit comments

Comments
 (0)