From 242bcdbadc280c15623332694c557d64a77abdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Fri, 1 Jun 2018 14:37:10 +0200 Subject: [PATCH] botserver: Add specific error message for unedited zuliprcs. Previously, when a user tried to run the Botserver with a zuliprc but forgot to set the bot name, they were told to edit the botserverrc file. However, the recommended approach is to specify the botname with the -b option. This commit adds an error message specific for this case. It recognizes zuliprc files by their section header `api`. --- zulip_botserver/zulip_botserver/server.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zulip_botserver/zulip_botserver/server.py b/zulip_botserver/zulip_botserver/server.py index 799ad34..cc3e819 100644 --- a/zulip_botserver/zulip_botserver/server.py +++ b/zulip_botserver/zulip_botserver/server.py @@ -57,10 +57,11 @@ def load_lib_modules(available_bots: List[str]) -> Dict[str, Any]: lib_module = import_module(module_name) bots_lib_module[bot] = lib_module except ImportError: - sys.exit( - "Error: Bot \"{}\" doesn't exist. " - "Please make sure you have set up the botserverrc file correctly.\n".format(bot) - ) + error_message = ("Error: Bot \"{}\" doesn't exist. Please make sure " + "you have set up the botserverrc file correctly.\n".format(bot)) + if bot == "api": + error_message += "Did you forget to specify the bot you want to run with -b ?" + sys.exit(error_message) return bots_lib_module