Skip to content

Commit 2034ef1

Browse files
committed
Return correct decline reason if bots/humans are generally deactivated
1 parent 2eece03 commit 2034ef1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

challenge_validator.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,25 @@ def get_decline_reason(self, challenge_event: dict[str, Any]) -> DeclineReason |
5151

5252
is_bot: bool = challenge_event["challenger"].get("title") == "BOT"
5353
modes = self.config.challenge.bot_modes if is_bot else self.config.challenge.human_modes
54-
if modes is None:
54+
if not modes:
5555
if is_bot:
5656
print("Bots are not allowed according to config.")
5757
return DeclineReason.NO_BOT
5858

5959
print("Only bots are allowed according to config.")
6060
return DeclineReason.ONLY_BOT
6161

62-
increment: int = challenge_event["timeControl"]["increment"]
63-
initial: int = challenge_event["timeControl"]["limit"]
6462
speeds = self.config.challenge.bot_time_controls if is_bot else self.config.challenge.human_time_controls
6563
if not speeds:
66-
print("No time control is allowed according to config.")
67-
return DeclineReason.GENERIC
64+
if is_bot:
65+
print("Bots are not allowed according to config.")
66+
return DeclineReason.NO_BOT
6867

68+
print("Only bots are allowed according to config.")
69+
return DeclineReason.ONLY_BOT
70+
71+
initial: int = challenge_event["timeControl"]["limit"]
72+
increment: int = challenge_event["timeControl"]["increment"]
6973
time_controls = self.bot_time_controls if is_bot else self.human_time_controls
7074
if speed not in speeds and (initial, increment) not in time_controls:
7175
print(f'Time control "{speed}" is not allowed according to config.')

0 commit comments

Comments
 (0)