contrib bots: john bot can reply back in the same chat.

No need to create an extra "VirtualHelp" stream.
This commit is contained in:
Abhijeet Kaur 2017-03-06 00:46:14 +05:30 committed by showell
parent d90906c521
commit 36bbad3c14
1 changed files with 19 additions and 8 deletions

View File

@ -109,17 +109,28 @@ class JohnHandler(object):
def usage(self): def usage(self):
return ''' return '''
Before running this, make sure to create a stream This bot aims to be Zulip's virtual assistant. It
called "VirtualHelp" that your API user can send to. 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): def handle_message(self, message, client, state_handler):
original_content = message['content'] original_content = message['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( client.send_message(dict(
type='stream', type='stream',
to='VirtualHelp', to=message['display_recipient'],
subject="John", subject=message['subject'],
content=str(bota.get_response(original_content)) content=bot_response,
)) ))
handler_class = JohnHandler handler_class = JohnHandler