Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matchmaking pull back #901

Merged

Conversation

MarkZH
Copy link
Collaborator

@MarkZH MarkZH commented Feb 3, 2024

Type of pull request:

  • Bug fix
  • Feature
  • Other

Description:

Simplify how the Matchmaking class handles the challenge_id string and remove the need to pass instances outside of lichess_bot_main().

  1. In handle_challenge(), use Challenge.from_self instead of chlng.id != matchmaker.challenge_id to prevent declining challenges originating from the user's bot. The Matchmaker instance is no longer needed as an argument.
  2. Before calling play_game(), matchmaker.challegne_id is already cleared in matchmaker.accepted_challenge(). There's no need to do so in play_game(), so there's no need for matchmaker to be a parameter.
  3. Create a method for clearing the Matchmaker.challenge_id in order to consolidate repeated code. Should we ever want to allow for multiple matchmaking challenges at once, this should make that simpler to implement.

Related Issues:

Inspired by discussion #883

Checklist:

  • I have read and followed the contribution guidelines.
  • I have added necessary documentation (if applicable).
  • The changes pass all existing tests.

Screenshots/logs (if applicable):

N/A

This is already done in Matchmaker.accepted_challenge()
A bot does not need to respond to challenges from itself.
Instead of checking Matchmaker.challenge_id, use
Challenge.from_self. Plus, this change handles the case where
if the bot's user manually creates a challenge for the bot on
the lichess website.
This method names the purpose of setting challenge_id
to the empty string.
@AttackingOrDefending AttackingOrDefending merged commit 180edae into lichess-bot-devs:master Feb 3, 2024
15 checks passed
@MarkZH MarkZH deleted the matchmaking-pull-back branch February 3, 2024 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants