Revert to sender attribute as more clear now

This commit is contained in:
Luke Murphy 2021-01-13 14:51:23 +01:00
parent 93ac2620e0
commit cf93c07294
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 5 additions and 6 deletions

View File

@ -48,11 +48,9 @@ class EchoBot(Bot):
"""
def react(self, message):
if message.type == "chat":
# Reply to direct messages
self.reply(message.body, to=message.source)
self.reply(message.body, to=message.sender)
if message.type == "groupchat" and "echobot" in message.body:
# Parse and reply group chat messages
_, to_echo = message.body.split(":")
self.reply(to_echo, room=message.room)
```
@ -101,7 +99,8 @@ accepts a `message` argument.
Attributes:
- **body**: the body of the message
- **source**: where the message came from (can be a user or a room)
- **sender**: the user the message came from
- **room**: the room the message came from
- **receiver**: the receiver of the message
- **nickname**: the nickname of the sender
- **type**: the type of message (`chat` or `groupchat`)

View File

@ -21,7 +21,7 @@ class SimpleMessage:
return self.message["body"]
@property
def source(self):
def sender(self):
return self.message["from"]
@property
@ -196,7 +196,7 @@ class EchoBot(Bot):
def react(self, message):
"""Send back what we get."""
if message.type == "chat":
self.reply(message.body, to=message.source)
self.reply(message.body, to=message.sender)
if message.type == "groupchat" and "echobot" in message.body:
_, to_echo = message.body.split(":")