aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2015-01-18 15:49:06 -0800
committerRyan Huber <rhuber@gmail.com>2015-01-18 15:49:06 -0800
commitc50bca3b8b06a35e580853abdf9010045abdc1ea (patch)
tree14015ec79db2d60b72d36cffdc1119ab19f517a7 /wee_slack.py
parente7d9d7514530d78c8988e18fc9e5dba87e505f81 (diff)
downloadwee-slack-c50bca3b8b06a35e580853abdf9010045abdc1ea.tar.gz
catch race cond where quit unjoins channels
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index fa7167c..83f465a 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1185,12 +1185,12 @@ def slack_never_away_cb(data, remaining):
def async_slack_api_request(domain, token, request, post_data, priority=False):
- post_data["token"] = token
- url = 'https://{}/api/{}'.format(domain, request)
- command = 'curl -s --data "{}" {}'.format(urllib.urlencode(post_data), url)
- print command
- context = pickle.dumps({"request": request, "token": token, "post_data": post_data})
- w.hook_process(command, 20000, "url_processor_cb", context)
+ if not STOP_TALKING_TO_SLACK:
+ post_data["token"] = token
+ url = 'https://{}/api/{}'.format(domain, request)
+ command = 'curl -s --data "{}" {}'.format(urllib.urlencode(post_data), url)
+ context = pickle.dumps({"request": request, "token": token, "post_data": post_data})
+ w.hook_process(command, 20000, "url_processor_cb", context)
# funny, right?
big_data = {}
@@ -1317,6 +1317,11 @@ def config_changed_cb(data, option, value):
create_slack_debug_buffer()
return w.WEECHAT_RC_OK
+def quit_notification_cb(signal, sig_type, data):
+ global STOP_TALKING_TO_SLACK
+ STOP_TALKING_TO_SLACK = True
+ cache_write_cb("", "")
+
# END Utility Methods
# Main
@@ -1326,6 +1331,7 @@ if __name__ == "__main__":
WEECHAT_HOME = w.info_get("weechat_dir", "")
CACHE_NAME = "slack.cache"
+ STOP_TALKING_TO_SLACK = False
if not w.config_get_plugin('slack_api_token'):
w.config_set_plugin('slack_api_token', "INSERT VALID KEY HERE!")
@@ -1386,6 +1392,7 @@ if __name__ == "__main__":
w.hook_signal('buffer_switch', "buffer_switch_cb", "")
w.hook_signal('window_switch', "buffer_switch_cb", "")
w.hook_signal('input_text_changed', "typing_notification_cb", "")
+ w.hook_signal('quit', "quit_notification_cb", "")
w.hook_command('slack', 'Plugin to allow typing notification and sync of read markers for slack.com', 'stuff', 'stuff2', '|'.join(cmds.keys()), 'slack_command_cb', '')
w.hook_command('me', '', 'stuff', 'stuff2', '', 'me_command_cb', '')
# w.hook_command('me', 'me_command_cb', '')