diff options
author | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2018-01-15 17:09:58 -0500 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2018-01-17 19:02:19 -0500 |
commit | 2d8e73d041605ea81e099e6be30b8524b5740500 (patch) | |
tree | b3a3adff561d4e9d561698f856dd327ff4a9b418 /wee_slack.py | |
parent | 72e4149ce3bdc87536d73ca5b77838734d9dced7 (diff) | |
download | wee-slack-2d8e73d041605ea81e099e6be30b8524b5740500.tar.gz |
add token once oauth completes
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py index 1e212a9..46cc96b 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2992,8 +2992,18 @@ def command_register(data, current_buffer, args): ).format(CLIENT_ID, CLIENT_SECRET, aargs[1]) ret = urllib.urlopen(uri).read() d = json.loads(ret) - if d["ok"] == True: - w.prnt(current_buffer, "Success! Access token is: " + d['access_token']) + if d["ok"]: + if config.is_default('slack_api_token'): + w.config_set_plugin('slack_api_token', d['access_token']) + else: + # Add new token to existing set, joined by comma. + tok = config.get_string('slack_api_token') + w.config_set_plugin('slack_api_token', + ','.join([tok, d['access_token']])) + w.prnt(current_buffer, + "Success! Added team \"%s\"" % (d['team_name'],)) + w.prnt(current_buffer, + "Please reload wee-slack") else: w.prnt(current_buffer, "Failed! Error is: " + d['error']) @@ -3649,6 +3659,10 @@ class PluginConfig(object): def get_int(self, key): return int(w.config_get_plugin(key)) + def is_default(self, key): + default = self.default_settings.get(key).default + return w.config_get_plugin(key) == default + get_debug_level = get_int get_group_name_prefix = get_string get_map_underline_to = get_string |