mirror of https://github.com/zulip/zulip.git
embedded bots: Properly reply to PMs and streams
This fixes an exception occurring when engaging an embedded bot in a PM, makes it respond as itself instead of the sender, and makes it respond to the PM conversation it is engaded in.
This commit is contained in:
parent
d0c0b148b3
commit
0473692abd
|
@ -84,9 +84,10 @@ class EmbeddedBotHandler(object):
|
||||||
def send_message(self, message):
|
def send_message(self, message):
|
||||||
# type: (Dict[str, Any]) -> None
|
# type: (Dict[str, Any]) -> None
|
||||||
if self._rate_limit.is_legal():
|
if self._rate_limit.is_legal():
|
||||||
internal_send_message(realm=self.user_profile.realm, sender_email=message['sender_email'],
|
recipients = message['to'] if message['type'] == 'stream' else ','.join(message['to'])
|
||||||
recipient_type_name=message['type'], recipients=message['to'],
|
internal_send_message(realm=self.user_profile.realm, sender_email=self.user_profile.email,
|
||||||
subject=message['subject'], content=message['content'])
|
recipient_type_name=message['type'], recipients=recipients,
|
||||||
|
subject=message.get('subject', None), content=message['content'])
|
||||||
else:
|
else:
|
||||||
self._rate_limit.show_error_and_exit()
|
self._rate_limit.show_error_and_exit()
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ class EmbeddedBotHandler(object):
|
||||||
if message['type'] == 'private':
|
if message['type'] == 'private':
|
||||||
self.send_message(dict(
|
self.send_message(dict(
|
||||||
type='private',
|
type='private',
|
||||||
to=[x['email'] for x in message['display_recipient'] if self.email != x['email']],
|
to=[x['email'] for x in message['display_recipient']],
|
||||||
content=response,
|
content=response,
|
||||||
sender_email=message['sender_email'],
|
sender_email=message['sender_email'],
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in New Issue