diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-05-25 16:01:41 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-05-25 16:01:41 -0700 |
commit | b730ea6eef1fc1e0ce3437aa9b78c364248bb876 (patch) | |
tree | 6f27228fc9f5f80cdbb45e08cf1b1310ef3f0b38 /wee_slack.py | |
parent | aa8b3d22f36c4357cd8d4889ecf95da2d1869af0 (diff) | |
download | wee-slack-b730ea6eef1fc1e0ce3437aa9b78c364248bb876.tar.gz |
don't add things that don't get replies
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py index 8de408b..11d22e1 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -213,11 +213,12 @@ class SlackServer(object): self.communication_counter += 1 return self.communication_counter - def send_to_websocket(self, data): + def send_to_websocket(self, data, expect_reply=True): data["id"] = self.get_communication_id() message = json.dumps(data) try: - self.message_buffer[data["id"]] = data + if expect_reply: + self.message_buffer[data["id"]] = data self.ws.send(message) dbg("Sent {}...".format(message[:100])) except: @@ -260,8 +261,10 @@ class SlackServer(object): resend = self.message_buffer.pop(message_id) dbg("Resent failed message.") self.send_to_websocket(resend) - #sleep to prevent being disconnected by websocket server - time.sleep(1) + #sleep to prevent being disconnected by websocket server + time.sleep(1) + else: + self.message_buffer.pop(message_id) return True else: w.prnt("", "\n!! slack.com login error: " + login_data["error"] + "\n Please check your API token with\n \"/set plugins.var.python.slack_extension.slack_api_token (token)\"\n\n ") @@ -1415,7 +1418,7 @@ def typing_notification_cb(signal, sig_type, data): if channel: identifier = channel.identifier request = {"type": "typing", "channel": identifier} - channel.server.send_to_websocket(request) + channel.server.send_to_websocket(request, expect_reply=False) typing_timer = now return w.WEECHAT_RC_OK @@ -1444,7 +1447,7 @@ def slack_never_away_cb(data, remaining): identifier = server.channels.find("slackbot").identifier request = {"type": "typing", "channel": identifier} #request = {"type":"typing","channel":"slackbot"} - server.send_to_websocket(request) + server.send_to_websocket(request, expect_reply=False) return w.WEECHAT_RC_OK # Slack specific requests |