From d6b4fa2e9f3557e06881d9788e0b143cb1c4eeab Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sat, 28 Mar 2026 14:01:01 -0700 Subject: [PATCH] fix: strip @botname from commands so /new@TigerNanoBot resolves correctly (#3581) Commands sent directly to the bot in groups include @botname suffix (e.g. /compress@TigerNanoBot). get_command() now strips the @anything part before lookup, matching how Telegram bot menu generates commands. Fixes all slash commands silently doing nothing when sent with @mention. Co-authored-by: MacroAnarchy --- gateway/platforms/base.py | 5 ++++- tests/gateway/test_platform_base.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gateway/platforms/base.py b/gateway/platforms/base.py index 7f72635b6d..e3668774e8 100644 --- a/gateway/platforms/base.py +++ b/gateway/platforms/base.py @@ -333,7 +333,10 @@ class MessageEvent: return None # Split on space and get first word, strip the / parts = self.text.split(maxsplit=1) - return parts[0][1:].lower() if parts else None + raw = parts[0][1:].lower() if parts else None + if raw and "@" in raw: + raw = raw.split("@", 1)[0] + return raw def get_command_args(self) -> str: """Get the arguments after a command.""" diff --git a/tests/gateway/test_platform_base.py b/tests/gateway/test_platform_base.py index 1aa0e11445..13b52f24f1 100644 --- a/tests/gateway/test_platform_base.py +++ b/tests/gateway/test_platform_base.py @@ -62,6 +62,18 @@ class TestMessageEventGetCommand: event = MessageEvent(text="/") assert event.get_command() == "" + def test_command_with_at_botname(self): + event = MessageEvent(text="/new@TigerNanoBot") + assert event.get_command() == "new" + + def test_command_with_at_botname_and_args(self): + event = MessageEvent(text="/compress@TigerNanoBot") + assert event.get_command() == "compress" + + def test_command_mixed_case_with_at_botname(self): + event = MessageEvent(text="/RESET@TigerNanoBot") + assert event.get_command() == "reset" + class TestMessageEventGetCommandArgs: def test_command_with_args(self):