From a32446f557c07de362f79a7141d6bd3f7d6d465a Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Wed, 22 Nov 2017 08:42:07 -0800 Subject: [PATCH] Report client.get_profile() errors nicely (e.g. API key). This patch is particularly useful in the scenario that your API key is wrong or out of date, but it's targeted more generally at any error that `client.get_profile()` reports. --- zulip_bots/zulip_bots/lib.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/zulip_bots/zulip_bots/lib.py b/zulip_bots/zulip_bots/lib.py index 12eca3b..cf289da 100644 --- a/zulip_bots/zulip_bots/lib.py +++ b/zulip_bots/zulip_bots/lib.py @@ -106,6 +106,13 @@ class ExternalBotHandler(object): '''.format(e)) sys.exit(1) + if user_profile.get('result') == 'error': + msg = user_profile.get('msg', 'unknown') + print(''' + ERROR: {} + '''.format(msg)) + sys.exit(1) + self._rate_limit = RateLimit(20, 5) self._client = client self._root_dir = root_dir