From 4c91db443b108bb4aaf8a0cda8122e32c4e5c910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Mon, 27 May 2024 00:10:30 +0200 Subject: [PATCH 1/3] Treat any command that starts with `eval` as `eval` i.e. `!eval`, `!eval1`, `!evalplease`, `!eval with spaces` --- lib/conversation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/conversation.py b/lib/conversation.py index bbc363b3c..6a7e253d3 100644 --- a/lib/conversation.py +++ b/lib/conversation.py @@ -67,6 +67,7 @@ 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") elif cmd == "wait" and self.game.is_abortable(): @@ -77,10 +78,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: From c07f4b8f2fa75da7035c300b6c03624d32d96775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Mon, 27 May 2024 11:55:33 +0200 Subject: [PATCH 2/3] Update supported commands text to reflect the change --- lib/conversation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/conversation.py b/lib/conversation.py index 6a7e253d3..772a8602c 100644 --- a/lib/conversation.py +++ b/lib/conversation.py @@ -69,7 +69,7 @@ def command(self, line: ChatLine, cmd: str) -> None: 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...") From 7bb0db5a5748c14afb4eeac4c7a22eccdd7096ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Mon, 27 May 2024 20:08:28 +0200 Subject: [PATCH 3/3] Split long line --- lib/conversation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/conversation.py b/lib/conversation.py index 772a8602c..17386e8cc 100644 --- a/lib/conversation.py +++ b/lib/conversation.py @@ -69,7 +69,9 @@ def command(self, line: ChatLine, cmd: str) -> None: 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 (or any text starting with !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...")