diff --git a/royalnet/bots/discord.py b/royalnet/bots/discord.py index db29fad9..936d40a2 100644 --- a/royalnet/bots/discord.py +++ b/royalnet/bots/discord.py @@ -108,6 +108,9 @@ class DiscordBot(GenericBot): # Skip non-text messages if not text: return + # Skip non-command updates + if not text.startswith(self.command_prefix): + return # Skip bot messages author: typing.Union[discord.User] = message.author if author.bot: diff --git a/royalnet/bots/generic.py b/royalnet/bots/generic.py index 3c26fbff..05aaf66d 100644 --- a/royalnet/bots/generic.py +++ b/royalnet/bots/generic.py @@ -22,6 +22,7 @@ class GenericBot: error_command: typing.Type[Command]) -> None: """Generate the ``commands`` dictionary required to handle incoming messages, and the ``network_handlers`` dictionary required to handle incoming requests.""" log.debug(f"Now generating commands") + self.command_prefix = command_prefix self.commands: typing.Dict[str, typing.Type[Command]] = {} self.network_handlers: typing.Dict[str, typing.Type[NetworkHandler]] = {} for command in commands: diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 019be23a..b58c1a2b 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -105,6 +105,9 @@ class TelegramBot(GenericBot): # No text or caption, ignore the message if text is None: return + # Skip non-command updates + if not text.startswith(self.command_prefix): + return # Find and clean parameters command_text, *parameters = text.split(" ") command_name = command_text.replace(f"@{self.client.username}", "").lower()