From 75794acc4694ecc7505c7c6eb9c0268e963e672c Mon Sep 17 00:00:00 2001 From: Krzysztof Krzysztof Date: Tue, 23 May 2017 17:56:51 -0700 Subject: [PATCH] bots: Correct weird behavior of followup bot for empty messages. Before it sends an empty message to followup stream, now it sends a help message back to the user/stream where it was mentioned. --- contrib_bots/bots/followup/followup.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/contrib_bots/bots/followup/followup.py b/contrib_bots/bots/followup/followup.py index 38fef504b8..324349112e 100644 --- a/contrib_bots/bots/followup/followup.py +++ b/contrib_bots/bots/followup/followup.py @@ -23,18 +23,22 @@ class FollowupHandler(object): ''' def handle_message(self, message, client, state_handler): - bot_response = self.get_bot_followup_response(message) - client.send_message(dict( - type='stream', - to='followup', - subject=message['sender_email'], - content=bot_response, - )) + if message['content'] == '': + bot_response = "Please specify the message you want to send to followup stream after @mention-bot" + client.send_reply(message, bot_response) + else: + bot_response = self.get_bot_followup_response(message) + client.send_message(dict( + type='stream', + to='followup', + subject=message['sender_email'], + content=bot_response, + )) def get_bot_followup_response(self, message): original_content = message['content'] original_sender = message['sender_email'] - temp_content = 'from %s:' % (original_sender,) + temp_content = 'from %s: ' % (original_sender,) new_content = temp_content + original_content return new_content