diff --git a/zulip_bots/zulip_bots/simple_lib.py b/zulip_bots/zulip_bots/simple_lib.py index 393ce2f..ca63293 100644 --- a/zulip_bots/zulip_bots/simple_lib.py +++ b/zulip_bots/zulip_bots/simple_lib.py @@ -1,4 +1,5 @@ import configparser +import sys class SimpleStorage: def __init__(self): @@ -49,10 +50,7 @@ class TerminalBotHandler: return self.message_server.send(message) def send_reply(self, message, response): - print(''' - reply: - {} - '''.format(response)) + print("\nReply from the bot is printed between the dotted lines:\n-------\n{}\n-------".format(response)) response_message = dict( content=response ) diff --git a/zulip_bots/zulip_bots/terminal.py b/zulip_bots/zulip_bots/terminal.py index 9e499a9..05925e7 100644 --- a/zulip_bots/zulip_bots/terminal.py +++ b/zulip_bots/zulip_bots/terminal.py @@ -56,18 +56,23 @@ def main(): sender_email = 'foo_sender@zulip.com' - while True: - content = input('Enter your message: ') + try: + while True: + content = input('Enter your message: ') - message = dict( - content=content, - sender_email=sender_email, - display_recipient=sender_email, - ) - message_handler.handle_message( - message=message, - bot_handler=bot_handler, - ) + message = dict( + content=content, + sender_email=sender_email, + display_recipient=sender_email, + ) + message_handler.handle_message( + message=message, + bot_handler=bot_handler, + ) + except KeyboardException: + print("\n\nOk, if you're happy with your terminal-based testing, try it out with a Zulip server.", + "\nYou can refer to https://zulipchat.com/api/running-bots#running-a-bot.") + sys.exit(1) if __name__ == '__main__': main()