Use Timers instead of bools to filter opponents to allow temporary stops to challenges#1141
Merged
AttackingOrDefending merged 10 commits intolichess-bot-devs:masterfrom Oct 9, 2025
Conversation
This will allow for filters to expire in case challenge declinations are for temporary reasons. Also, in the case of an opponent reaching the 100-game daily limit, this will be useful for trying again in the time given in the interval.
In an upcoming lichess update, challenging an opponent that has played 100 bot games will result in a similar error response to when the user's bot has played 100 bot games. This change distinguishes between them by checking if the error message contains the opponent's name. This could also be distinguished by checking if the status code is 429 (user's bot) or 400 (opponent bot). But that information isn't returned from the Lichess.challenge() call.
Collaborator
Author
|
This PR is a draft since the change in the linked commit has not been deployed yet. This needs testing with a live bot session. |
A status code of 400 indicates that the opponent is rate limited, while 429 indicates that the bot is limited. Also, put who is rate limited (if anyone) in the challenge response so the Matchmaking class can use it.
Don't set rate limit when opponent is rate limited (400 status code).
Collaborator
Author
|
I think this is ready for testing beyond my computer. There is a bit of redundancy. The player timeout after 100 games is implemented in both the |
AttackingOrDefending
approved these changes
Oct 9, 2025
5749ba8
into
lichess-bot-devs:master
23 checks passed
r0950336
pushed a commit
to r0950336/lichess-bot
that referenced
this pull request
Dec 31, 2025
…ops to challenges (lichess-bot-devs#1141) * Make matchmaking challenge filters time-limited This will allow for filters to expire in case challenge declinations are for temporary reasons. Also, in the case of an opponent reaching the 100-game daily limit, this will be useful for trying again in the time given in the interval. * Factor out variable * Distinguish between bot limit and opponent limit In an upcoming lichess update, challenging an opponent that has played 100 bot games will result in a similar error response to when the user's bot has played 100 bot games. This change distinguishes between them by checking if the error message contains the opponent's name. This could also be distinguished by checking if the status code is 429 (user's bot) or 400 (opponent bot). But that information isn't returned from the Lichess.challenge() call. * Be more specific about challenge pause delay * Factor out function to get timeout from error * Use status code to tell who is rate limited A status code of 400 indicates that the opponent is rate limited, while 429 indicates that the bot is limited. Also, put who is rate limited (if anyone) in the challenge response so the Matchmaking class can use it. * Simplify challenge control flow * Only set rate limit when bot gets 429 status code Don't set rate limit when opponent is rate limited (400 status code). * Create a method to handle responses to challenges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of pull request:
Description:
Instead of preventing the challenging of another bot that declines a challenge for the rest of the lichess-bot run, default to a one-day timeout. Block lists still work, but are implemented as a 10-year timeout.
The primary reason for this PR is an upcoming change in lichess. Challenging another bot that has already played 100 games today will result in a 400 status code and an error message with information about when the bot's timeout will expire.
Related Issues:
This commit to lila tells bots how long to wait before challenging another bot that has reached the 100-bot-game per day limit: lichess-org/lila@53f2c4d
Checklist:
Screenshots/logs (if applicable):