diff options
author | Ryan Huber <rhuber@gmail.com> | 2014-07-17 15:32:26 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2014-07-17 15:32:26 -0700 |
commit | f0f4ee647f184394bd013986b07abed81671aee8 (patch) | |
tree | 9ad7bb2c2b4e050875978f810264bdcd7371e962 | |
parent | 8303844847135c2f628818ffc9e93468612aa4b5 (diff) | |
download | wee-slack-f0f4ee647f184394bd013986b07abed81671aee8.tar.gz |
handle bad token
-rw-r--r-- | wee_slack.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2f6fb08..97a28c9 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -300,18 +300,21 @@ def connect_to_slack(): if reply.code == 200: data = reply.read() login_data = json.loads(data) - nick = login_data["self"]["name"] - domain = login_data["team"]["domain"] + ".slack.com" + if login_data["ok"] == True: + nick = login_data["self"]["name"] + domain = login_data["team"]["domain"] + ".slack.com" - create_slack_lookup_hashes(login_data) - create_slack_websocket(login_data) + create_slack_lookup_hashes(login_data) + create_slack_websocket(login_data) - general_buffer_ptr = w.buffer_search("",server+".#general") - nick_ptr = w.nicklist_search_nick(general_buffer_ptr,'',nick) - name = w.nicklist_nick_get_string(general_buffer_ptr,nick,'name') + general_buffer_ptr = w.buffer_search("",server+".#general") + nick_ptr = w.nicklist_search_nick(general_buffer_ptr,'',nick) + name = w.nicklist_nick_get_string(general_buffer_ptr,nick,'name') - connected = True - return True + connected = True + return True + else: + w.prnt("", "\n!! slack.com login error: " + login_data["error"] + "\n\n") else: connected = False return False |