diff --git a/CHANGELOG.md b/CHANGELOG.md index 164e33f..44f60f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # xbotlib x.x.x (UNRELEASED) +# xbotlib 0.13.0 (2021-01-18) + +- Allow commands to be detected in all parts of the message + # xbotlib 0.12.4 (2021-01-18) - Allow `Bot.group` to respond to file uploads ([#32](https://git.autonomic.zone/decentral1se/xbotlib/issues/32)) diff --git a/README.md b/README.md index a11f6e5..ebd63c5 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,9 @@ There are also more general status commands which all bots respond to. - `@bots`: status check on who is a bot in the group chat +These commands will be detected in any part of the message sent to the bot. So +you can write `echobot, can we see your @uptime`, or `I'd love to know which @bots are here.` + ### Avatars By default, `xbotlib` will look for an `avatar.png` (so far tested with `.png` diff --git a/pyproject.toml b/pyproject.toml index 60ac0c4..6a09ff6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api" [tool.poetry] name = "xbotlib" -version = "0.12.4" +version = "0.13.0" description = "XMPP bots for humans" authors = ["decentral1se "] maintainers = ["decentral1se "] diff --git a/xbotlib.py b/xbotlib.py index 2403eb5..bbf1818 100644 --- a/xbotlib.py +++ b/xbotlib.py @@ -513,8 +513,9 @@ class Bot(ClientXMPP): """Handle group chat message events.""" message = SimpleMessage(message, self) - if message.text.startswith("@"): - return self.meta(message, room=message.room) + if "@" in message.text: + if self.meta(message, room=message.room): + return miss = message.type not in self.GROUP_MESSAGE_TYPES loop = message.nick == self.nick @@ -523,7 +524,7 @@ class Bot(ClientXMPP): if miss or other or loop: return - if message.content.startswith("@"): + if "@" in message.content: if self.command(message, room=message.room): return @@ -613,14 +614,14 @@ class Bot(ClientXMPP): def meta(self, message, **kwargs): """Handle meta command invocations.""" - if message.text.startswith("@bots"): + if "@bots" in message.text: return self.reply("🖐️", **kwargs) def command(self, message, **kwargs): """Handle command invocations.""" - if message.content.startswith("@uptime"): + if "@uptime" in message.content: return self.reply(self.uptime, **kwargs) - elif message.content.startswith("@help"): + elif "@help" in message.content: try: return self.reply(cleandoc(self.help), **kwargs) except AttributeError: