From 45e0f77298b153a382ea57e68136d9e610acfcc8 Mon Sep 17 00:00:00 2001 From: derAnfaenger Date: Wed, 24 May 2017 02:12:36 +0200 Subject: [PATCH] bots: Allow bots to update messages. --- contrib_bots/bot_lib.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib_bots/bot_lib.py b/contrib_bots/bot_lib.py index e1f7e89..a7100f8 100644 --- a/contrib_bots/bot_lib.py +++ b/contrib_bots/bot_lib.py @@ -49,7 +49,16 @@ class BotHandlerApi(object): def send_message(self, *args, **kwargs): 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: logging.error('-----> !*!*!*MESSAGE RATE LIMIT REACHED, EXITING*!*!*! <-----\n' 'Is your bot trapped in an infinite loop by reacting to' @@ -58,13 +67,13 @@ class BotHandlerApi(object): def send_reply(self, message, response): if message['type'] == 'private': - self.send_message(dict( + return self.send_message(dict( type='private', to=[x['email'] for x in message['display_recipient'] if self.email != x['email']], content=response, )) else: - self.send_message(dict( + return self.send_message(dict( type='stream', to=message['display_recipient'], subject=message['subject'],