Skip to content

feat: add rating filtering for incoming challenges#1190

Merged
AttackingOrDefending merged 3 commits intolichess-bot-devs:masterfrom
farhadzaidi:incoming-challenge-rating-filter
Mar 18, 2026
Merged

feat: add rating filtering for incoming challenges#1190
AttackingOrDefending merged 3 commits intolichess-bot-devs:masterfrom
farhadzaidi:incoming-challenge-rating-filter

Conversation

@farhadzaidi
Copy link
Copy Markdown
Contributor

Type of pull request:

  • Bug fix
  • Feature
  • Other

Description:

Add min_rating, max_rating, and rating_difference options to the challenge config section, allowing bots to filter incoming challenges by the challenger's rating. This mirrors the existing rating filtering available for outgoing matchmaking challenges.

Related Issues:

N/A

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

@farhadzaidi farhadzaidi changed the title Add rating filtering for incoming challenges feat: add rating filtering for incoming challenges Mar 8, 2026
@farhadzaidi farhadzaidi force-pushed the incoming-challenge-rating-filter branch from 60d7287 to f0e0173 Compare March 9, 2026 16:34
Comment thread lib/model.py Outdated
def is_supported(self, config: Configuration, recent_bot_challenges: defaultdict[str, list[Timer]],
opponent_engagements: Counter[str], online_block_list: OnlineBlocklist) -> tuple[bool, str]:
opponent_engagements: Counter[str], online_block_list: OnlineBlocklist,
user_profile: UserProfileType | None = None) -> tuple[bool, str]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the type annotation UserProfileType | None instead of UserProfileType? Every call to is_supported() has a user_profile parameter.

Copy link
Copy Markdown
Contributor Author

@farhadzaidi farhadzaidi Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the type annotation to remove the None fallback.

Comment thread lib/model.py Outdated
or self.decline_due_to(self.is_supported_time_control(config), "timeControl")
or self.decline_due_to(self.is_supported_variant(config), "variant")
or self.decline_due_to(self.is_supported_mode(config), "casual" if self.rated else "rated")
or self.decline_due_to(self.is_supported_rating(config, user_profile or {}), "generic")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the type of user_profile is UserProfileType, then the or {} can be removed.

Copy link
Copy Markdown
Contributor Author

@farhadzaidi farhadzaidi Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the {} fallback from this call.

@AttackingOrDefending AttackingOrDefending merged commit 3917a5c into lichess-bot-devs:master Mar 18, 2026
23 checks passed
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.

3 participants