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`.
This commit is contained in:
Robert Hönig 2018-06-01 14:37:10 +02:00 committed by Tim Abbott
parent 3ddc8f9b5d
commit 242bcdbadc

View file

@ -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 <botname> ?"
sys.exit(error_message)
return bots_lib_module