Skip to content

Commit

Permalink
Allow all commands that start with !eval to overcome spam rules (li…
Browse files Browse the repository at this point in the history
…chess-bot-devs#967)

* Treat any command that starts with `eval` as `eval`

i.e. `!eval`, `!eval1`, `!evalplease`, `!eval with spaces`

* Update supported commands text to reflect the change

* Split long line
  • Loading branch information
eduherminio authored May 31, 2024
1 parent 85ef829 commit 7c83143
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ def command(self, line: ChatLine, cmd: str) -> None:
:param cmd: The command to react to.
"""
from_self = line.username == self.game.username
is_eval = cmd.startswith("eval")
if cmd == "commands" or cmd == "help":
self.send_reply(line, "Supported commands: !wait (wait a minute for my first move), !name, !howto, !eval, !queue")
self.send_reply(line, (
"Supported commands: !wait (wait a minute for my first move), !name, !howto, "
"!eval (or any text starting with !eval), !queue"))
elif cmd == "wait" and self.game.is_abortable():
self.game.ping(seconds(60), seconds(120), seconds(120))
self.send_reply(line, "Waiting 60 seconds...")
Expand All @@ -77,10 +80,10 @@ def command(self, line: ChatLine, cmd: str) -> None:
self.send_reply(line, f"{name} running {self.engine.name()} (lichess-bot v{self.version})")
elif cmd == "howto":
self.send_reply(line, "How to run: Check out 'Lichess Bot API'")
elif cmd == "eval" and (from_self or line.room == "spectator"):
elif is_eval and (from_self or line.room == "spectator"):
stats = self.engine.get_stats(for_chat=True)
self.send_reply(line, ", ".join(stats))
elif cmd == "eval":
elif is_eval:
self.send_reply(line, "I don't tell that to my opponent, sorry.")
elif cmd == "queue":
if self.challengers:
Expand Down

0 comments on commit 7c83143

Please sign in to comment.