!bots -> /bots

This commit is contained in:
Luke Murphy 2021-01-15 15:05:49 +01:00
parent 895d0c8787
commit 3e83a9390b
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -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 <lukewm@riseup.net>"]
maintainers = ["decentral1se <lukewm@riseup.net>"]

View File

@ -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")