bots: Allow bots to update messages.
This commit is contained in:
parent
bfb4ec78cc
commit
45e0f77298
|
@ -49,7 +49,16 @@ class BotHandlerApi(object):
|
||||||
|
|
||||||
def send_message(self, *args, **kwargs):
|
def send_message(self, *args, **kwargs):
|
||||||
if self._rate_limit.is_legal():
|
if self._rate_limit.is_legal():
|
||||||
self._client.send_message(*args, **kwargs)
|
return self._client.send_message(*args, **kwargs)
|
||||||
|
else:
|
||||||
|
logging.error('-----> !*!*!*MESSAGE RATE LIMIT REACHED, EXITING*!*!*! <-----\n'
|
||||||
|
'Is your bot trapped in an infinite loop by reacting to'
|
||||||
|
' its own messages?')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def update_message(self, *args, **kwargs):
|
||||||
|
if self._rate_limit.is_legal():
|
||||||
|
return self._client.update_message(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
logging.error('-----> !*!*!*MESSAGE RATE LIMIT REACHED, EXITING*!*!*! <-----\n'
|
logging.error('-----> !*!*!*MESSAGE RATE LIMIT REACHED, EXITING*!*!*! <-----\n'
|
||||||
'Is your bot trapped in an infinite loop by reacting to'
|
'Is your bot trapped in an infinite loop by reacting to'
|
||||||
|
@ -58,13 +67,13 @@ class BotHandlerApi(object):
|
||||||
|
|
||||||
def send_reply(self, message, response):
|
def send_reply(self, message, response):
|
||||||
if message['type'] == 'private':
|
if message['type'] == 'private':
|
||||||
self.send_message(dict(
|
return 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'] if self.email != x['email']],
|
||||||
content=response,
|
content=response,
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
self.send_message(dict(
|
return self.send_message(dict(
|
||||||
type='stream',
|
type='stream',
|
||||||
to=message['display_recipient'],
|
to=message['display_recipient'],
|
||||||
subject=message['subject'],
|
subject=message['subject'],
|
||||||
|
|
Loading…
Reference in a new issue