From 36bbad3c14d0e39f40eb5ca56a6fc9555cca5b16 Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Mon, 6 Mar 2017 00:46:14 +0530 Subject: [PATCH] contrib bots: john bot can reply back in the same chat. No need to create an extra "VirtualHelp" stream. --- contrib_bots/bots/john/john.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/contrib_bots/bots/john/john.py b/contrib_bots/bots/john/john.py index 27da5f08f5..21a9b86cb0 100644 --- a/contrib_bots/bots/john/john.py +++ b/contrib_bots/bots/john/john.py @@ -109,17 +109,28 @@ class JohnHandler(object): def usage(self): return ''' - Before running this, make sure to create a stream - called "VirtualHelp" that your API user can send to. + This bot aims to be Zulip's virtual assistant. It + finds the best match from a certain input. + Also understands the English language and can + mantain a conversation, joke and give useful information. ''' def handle_message(self, message, client, state_handler): original_content = message['content'] - client.send_message(dict( - type='stream', - to='VirtualHelp', - subject="John", - content=str(bota.get_response(original_content)) - )) + bot_response = str(bota.get_response(original_content)) + + if message['type'] == 'private': + client.send_message(dict( + type='private', + to=message['sender_email'], + content=bot_response, + )) + else: + client.send_message(dict( + type='stream', + to=message['display_recipient'], + subject=message['subject'], + content=bot_response, + )) handler_class = JohnHandler