diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b4aaae..f485ca0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # xbotlib x.x.x (UNRELEASED) +# xbotlib 0.3.0 (2021-01-10) + - Error out if you don't provide a `react` implementation +- Change `reply` to accept `body` as the first argument # xbotlib 0.2.0 (2021-01-10) diff --git a/README.md b/README.md index e0042d0..2da3f1d 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ from xbotlib import Bot class EchoBot(Bot): def react(self, message): if message.type == "chat": - self.reply(to=message.sender, body=message.body) + self.reply(message.body, to=message.sender) MyBot() ``` @@ -54,7 +54,7 @@ underling functions can be extended. For example, if you want to enable more plugins or add different functionality. If something feels awkward then please raise a ticket for that. Seamlessness is still a bitch but we're trying anyway. -### Bot.react +> Bot.react(message) A function which you define in your bot implementation in order to respond to chat messages. You can respond to both direct messages and group chat messages @@ -65,7 +65,7 @@ Arguments: - **message**: sent message and metadata (see [message](#message) reference below) -### Bot.reply +> Bot.reply(body, to=None, room=None) Send back a response to a direct chat message. @@ -75,9 +75,10 @@ Arguments: - **room**: which room to reply to (group chat) - **body**: the message to send -### Message +> EasyMessage -A simple message format. +A simple message format. This is the type that you work with when your function +accepts a `message` argument. Attributes: diff --git a/examples/echo.py b/examples/echo.py index bd1e55b..b7b888e 100644 --- a/examples/echo.py +++ b/examples/echo.py @@ -11,7 +11,7 @@ class EchoBot(Bot): def react(self, message): """Send back what we get.""" if message.type == "chat": - self.reply(to=message.sender, body=message.body) + self.reply(message.body, to=message.sender) EchoBot() diff --git a/examples/whisper.py b/examples/whisper.py index e8bfe97..90bde15 100644 --- a/examples/whisper.py +++ b/examples/whisper.py @@ -24,7 +24,7 @@ class WhisperBot(Bot): """Receive direct messages and pass them to group chats.""" if message.type == "chat" and "whisper" in message.body: _, room, whisper = message.body.split(":") - self.reply(room=room, body=f"*whispers* {whisper}") + self.reply(f"*whispers* {whisper}", room=room) WhisperBot() diff --git a/xbotlib.py b/xbotlib.py index 68a2abb..24b5075 100644 --- a/xbotlib.py +++ b/xbotlib.py @@ -124,7 +124,7 @@ class Bot(ClientXMPP): except KeyboardInterrupt: pass - def reply(self, to=None, room=None, body=None): + def reply(self, body, to=None, room=None): """Send back a reply.""" if to is None and room is None: message = "`to` or `room` arguments required for `reply`"