mirror of https://github.com/zulip/zulip.git
contrib bots: john bot can reply back in the same chat.
No need to create an extra "VirtualHelp" stream.
This commit is contained in:
parent
d90906c521
commit
36bbad3c14
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue