diff --git a/CHANGELOG.md b/CHANGELOG.md index 683128c..77a3afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # xbotlib x.x.x (UNRELEASED) +# xbotlib 0.9.0 (2021-01-15) + +- Re-worked `!bots` -> `/bots` + # xbotlib 0.8.2 (2021-01-15) - Add `!bots` command to summon status diff --git a/pyproject.toml b/pyproject.toml index 8109751..86e0c6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api" [tool.poetry] name = "xbotlib" -version = "0.8.2" +version = "0.9.0" description = "XMPP bots for humans" authors = ["decentral1se "] maintainers = ["decentral1se "] diff --git a/xbotlib.py b/xbotlib.py index 7416dcb..7d25393 100644 --- a/xbotlib.py +++ b/xbotlib.py @@ -213,6 +213,10 @@ class Bot(ClientXMPP): if message["type"] in ("chat", "normal"): _message = SimpleMessage(message) + if _message.body.startswith("/"): + self.meta(_message, to=_message.sender) + return + if _message.body.startswith("!"): self.command(_message, to=_message.sender) return @@ -258,6 +262,10 @@ class Bot(ClientXMPP): if message["mucnick"] != self.config.nick: _message = SimpleMessage(message) + if _message.body.startswith("/"): + self.meta(_message, room=_message.room) + return + if f"{self.nick}:!" in _message.body: self.command(_message, room=_message.room) return @@ -319,8 +327,15 @@ class Bot(ClientXMPP): self.reply(self.help, **kwargs) except AttributeError: self.reply("No help found 🤔️", **kwargs) - elif command == "bots" and "room" in kwargs: - self.reply("o/", **kwargs) + else: + self.log.error(f"'{command}' command is not recognised") + + def meta(self, message, **kwargs): + """Handle "/" style commands with built-in responses.""" + command = message.body.split("/")[-1] + + if command == "bots": + self.reply(f"🖐️", **kwargs) else: self.log.error(f"'{command}' command is not recognised")