Revert to sender attribute as more clear now
This commit is contained in:
parent
93ac2620e0
commit
cf93c07294
@ -48,11 +48,9 @@ class EchoBot(Bot):
|
|||||||
"""
|
"""
|
||||||
def react(self, message):
|
def react(self, message):
|
||||||
if message.type == "chat":
|
if message.type == "chat":
|
||||||
# Reply to direct messages
|
self.reply(message.body, to=message.sender)
|
||||||
self.reply(message.body, to=message.source)
|
|
||||||
|
|
||||||
if message.type == "groupchat" and "echobot" in message.body:
|
if message.type == "groupchat" and "echobot" in message.body:
|
||||||
# Parse and reply group chat messages
|
|
||||||
_, to_echo = message.body.split(":")
|
_, to_echo = message.body.split(":")
|
||||||
self.reply(to_echo, room=message.room)
|
self.reply(to_echo, room=message.room)
|
||||||
```
|
```
|
||||||
@ -101,7 +99,8 @@ accepts a `message` argument.
|
|||||||
Attributes:
|
Attributes:
|
||||||
|
|
||||||
- **body**: the body of the message
|
- **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
|
- **receiver**: the receiver of the message
|
||||||
- **nickname**: the nickname of the sender
|
- **nickname**: the nickname of the sender
|
||||||
- **type**: the type of message (`chat` or `groupchat`)
|
- **type**: the type of message (`chat` or `groupchat`)
|
||||||
|
@ -21,7 +21,7 @@ class SimpleMessage:
|
|||||||
return self.message["body"]
|
return self.message["body"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def source(self):
|
def sender(self):
|
||||||
return self.message["from"]
|
return self.message["from"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -196,7 +196,7 @@ class EchoBot(Bot):
|
|||||||
def react(self, message):
|
def react(self, message):
|
||||||
"""Send back what we get."""
|
"""Send back what we get."""
|
||||||
if message.type == "chat":
|
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:
|
if message.type == "groupchat" and "echobot" in message.body:
|
||||||
_, to_echo = message.body.split(":")
|
_, to_echo = message.body.split(":")
|
||||||
|
Reference in New Issue
Block a user