From f0f4ee647f184394bd013986b07abed81671aee8 Mon Sep 17 00:00:00 2001 From: Ryan Huber Date: Thu, 17 Jul 2014 15:32:26 -0700 Subject: handle bad token --- wee_slack.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'wee_slack.py') 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 -- cgit