aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTollef Fog Heen <tfheen@err.no>2016-11-28 21:07:03 +0100
committerTollef Fog Heen <tfheen@err.no>2016-11-28 21:07:03 +0100
commit12f022738915169683e6842e010b4061f918441f (patch)
treef0fb708b15b8b18be1553543fabb60f92dee104e /wee_slack.py
parentf1cb8051a5c021d895954efea46de8fca1ace904 (diff)
downloadwee-slack-12f022738915169683e6842e010b4061f918441f.tar.gz
Make it possible to set timeouts on slack URL comms
On very busy slack networks the default timeout of 20000 can be a problem. This timeout can mean that the extension is unable to download all the necesarry data before weechat times out the connection. This patch allows for the timeout to be adjusted so that for larger networks the end user can specify it. Based on #279 by @GregBowyer. Closes: #279
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1357b00..1329b30 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2225,7 +2225,7 @@ def async_slack_api_request(domain, token, request, post_data, priority=False):
context = pickle.dumps({"request": request, "token": token, "post_data": post_data})
params = {'useragent': 'wee_slack {}'.format(SCRIPT_VERSION)}
dbg("URL: {} context: {} params: {}".format(url, context, params))
- w.hook_process_hashtable(url, params, 20000, "url_processor_cb", context)
+ w.hook_process_hashtable(url, params, slack_timeout, "url_processor_cb", context)
def async_slack_api_upload_request(token, request, post_data, priority=False):
@@ -2234,7 +2234,7 @@ def async_slack_api_upload_request(token, request, post_data, priority=False):
file_path = os.path.expanduser(post_data["file"])
command = 'curl -F file=@{} -F channels={} -F token={} {}'.format(file_path, post_data["channels"], token, url)
context = pickle.dumps({"request": request, "token": token, "post_data": post_data})
- w.hook_process(command, 20000, "url_processor_cb", context)
+ w.hook_process(command, slack_timeout, "url_processor_cb", context)
# funny, right?
@@ -2372,7 +2372,7 @@ def create_slack_debug_buffer():
def config_changed_cb(data, option, value):
global slack_api_token, distracting_channels, colorize_nicks, colorize_private_chats, slack_debug, debug_mode, \
- unfurl_ignore_alt_text, colorize_messages, show_reaction_nicks
+ unfurl_ignore_alt_text, colorize_messages, show_reaction_nicks, slack_timeout
slack_api_token = w.config_get_plugin("slack_api_token")
@@ -2392,6 +2392,8 @@ def config_changed_cb(data, option, value):
if w.config_get_plugin('unfurl_ignore_alt_text') != "0":
unfurl_ignore_alt_text = True
+ slack_timeout = int(w.config_get_plugin('slack_timeout'))
+
return w.WEECHAT_RC_OK
@@ -2464,7 +2466,8 @@ if __name__ == "__main__":
w.config_set_plugin('switch_buffer_on_join', "1")
if not w.config_get_plugin('show_reaction_nicks'):
w.config_set_plugin('show_reaction_nicks', "0")
-
+ if not w.config_get_plugin('slack_timeout'):
+ w.config_set_plugin('slack_timeout', "20000")
if w.config_get_plugin('channels_not_on_current_server_color'):
w.config_option_unset('channels_not_on_current_server_color')