aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Huber <rhuber@gmail.com>2014-04-03 15:05:05 -0700
committerRyan Huber <rhuber@gmail.com>2014-04-03 15:05:05 -0700
commit267a7022585dfb11eedd1a2efa592c5475a41a0a (patch)
tree2f86c169a0d46f9514bfb3d9433530ac40c5b48a
parent139101472b3ac917fb981dbd22270b64b81be807 (diff)
downloadwee-slack-267a7022585dfb11eedd1a2efa592c5475a41a0a.tar.gz
add pinger
-rw-r--r--wee_slack.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 46dc20e..c17564e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -214,6 +214,18 @@ def typing_notification_cb(signal, sig_type, data):
pass
return w.WEECHAT_RC_OK
+#NOTE: figured i'd do this because they are
+def slack_ping_cb(data, remaining):
+ global counter
+ if counter > 999:
+ counter = 0
+ request = {"type":"ping","id":counter}
+ ws.send(json.dumps(request))
+ counter += 1
+ return w.WEECHAT_RC_OK
+
+### Slack specific requests
+
def slack_mark_channel_read(channel_id):
t = int(time.time())
if channel_id.startswith('C'):
@@ -221,8 +233,6 @@ def slack_mark_channel_read(channel_id):
elif channel_id.startswith('D'):
reply = async_slack_api_request(browser, "im.mark", {"channel":channel_id,"ts":t})
-### Slack specific requests
-
def create_browser_instance():
browser = mechanize.Browser()
browser.set_handle_robots(False)
@@ -368,9 +378,10 @@ if __name__ == "__main__":
timeout = w.config_get_plugin("timeout")
timer = time.time()
+ counter = 0
previous_buffer = None
- create_slack_buffer()
+ #create_slack_buffer()
browser = create_browser_instance()
stuff = connect_to_slack(browser)
@@ -391,6 +402,7 @@ if __name__ == "__main__":
w.hook_fd(ws.sock._sock.fileno(), 1, 0, 0, "slack_cb", "")
w.hook_timer(1000, 0, 0, "typing_update_cb", "")
w.hook_timer(1000 * 60, 0, 0, "keep_channel_read_cb", "")
+ w.hook_timer(1000 * 3, 0, 0, "slack_ping_cb", "")
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", "")