From 1dd905231f8cc7107819ac0e69b9b0110ffc772f Mon Sep 17 00:00:00 2001 From: Petter Wahlman Date: Tue, 26 May 2026 08:36:03 +0200 Subject: [PATCH] fix: skip random challenge when no bot is found 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 --- lib/matchmaking.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matchmaking.py b/lib/matchmaking.py index a4c182df8..53a0c477b 100644 --- a/lib/matchmaking.py +++ b/lib/matchmaking.py @@ -237,8 +237,13 @@ def challenge(self, active_games: set[str], challenge_queue: MULTIPROCESSING_LIS logger.info("Challenging a random bot") self.update_user_profile() bot_username, base_time, increment, days, variant, mode = self.choose_opponent() + if not bot_username: + logger.info("No challenge will be created.") + self.challenge_id = "" + return + logger.info(f"Will challenge {bot_username} for a {variant} game.") - challenge_id = self.create_challenge(bot_username, base_time, increment, days, variant, mode) if bot_username else "" + challenge_id = self.create_challenge(bot_username, base_time, increment, days, variant, mode) logger.info(f"Challenge id is {challenge_id or 'None'}.") self.challenge_id = challenge_id