Handle new error message when challenging bots#1137
Conversation
Reference issue: lichess-bot-devs#1135 Detect when the rate limiting status code (429) is due to issuing more than 100 challenges in a day. The change to matchmaking prevents adding other bots to the block list in case the error is due to this rate limit.
|
I'm submitting this as a draft since I have more changes planned. Plus, I want to make sure that I'm on the right track in implementing the change to the bot API. My next change is probably getting rid of |
The purpose of tracking daily challenges was to slow down the issuing of challenges when the rate limit of 400/day was being approached. However, now that the number of games is limited to 100/day (whether the bot issues or receives the challenge), this tracking is redundant. The rate at which challenges are issued is now entirely controlled by the matchmaking: challenge_timeout configuration, which specifies how long after a game ends to issue a new challenge.
Now that challenge times aren't recorded, there's no need for backdated Timers or the recording of when a Timer was created.
|
I don't think players will care if their 100 games/day limit is used up quickly or not. |
|
The |
Put the rate-limit timeout into the RateLimitedError exception so other parts of the program can use it. Add a rate-limit Timer to the Matchmaking class so that the user's logs aren't fill with rate-limited messages. Also, change the format of the "Next challenge will be created after" message to include the date since the delay may last into the next day.
This serves as a general rate limit on challenges and is still useful.
Create a function to handle the daily game limit. Update types to accomodate the response error message.
5f78477
into
lichess-bot-devs:master
Maybe they could care. Imagine you just made a tweak to your bot, and want to see it in action, but all 100 games were played because lichess-bot rushes them asap |
* Handle new error message when challenging bots Reference issue: lichess-bot-devs#1135 Detect when the rate limiting status code (429) is due to issuing more than 100 challenges in a day. The change to matchmaking prevents adding other bots to the block list in case the error is due to this rate limit. * Remove tracking of daily challenges The purpose of tracking daily challenges was to slow down the issuing of challenges when the rate limit of 400/day was being approached. However, now that the number of games is limited to 100/day (whether the bot issues or receives the challenge), this tracking is redundant. The rate at which challenges are issued is now entirely controlled by the matchmaking: challenge_timeout configuration, which specifies how long after a game ends to issue a new challenge. * Remove unneeded Timer attributes Now that challenge times aren't recorded, there's no need for backdated Timers or the recording of when a Timer was created. * Delete unused type * Put daily game limit info in user messages Put the rate-limit timeout into the RateLimitedError exception so other parts of the program can use it. Add a rate-limit Timer to the Matchmaking class so that the user's logs aren't fill with rate-limited messages. Also, change the format of the "Next challenge will be created after" message to include the date since the delay may last into the next day. * Put back Matchmaking.min_wait_time This serves as a general rate limit on challenges and is still useful. * Undo unneeded parenthesis move * Handle daily game limit on first failed challenge Create a function to handle the daily game limit. Update types to accomodate the response error message. * Update wiki regarding daily bot game limits
Detect when the rate limiting status code (429) is due to issuing a challenge after playing more than 100 games in a day. Use the message in the response to delay issuing another challenge.
Type of pull request:
Description:
The biggest change is setting the time delay according to the
["ratelimit"]["seconds"]field in the response.Related Issues:
Closes #1135
Checklist:
Screenshots/logs (if applicable):