diff options
author | Eric Wang <gnawrice@gmail.com> | 2017-10-08 23:49:21 -0700 |
---|---|---|
committer | Eric Wang <gnawrice@gmail.com> | 2017-10-16 15:32:19 -0700 |
commit | 9cddd64ae65bfcc920338a00fbfd6d49db12b456 (patch) | |
tree | d46b5a0eb6eedf366f66d80b49c037faf12328e6 /wee_slack.py | |
parent | 504411f48ebf1c5a6b8679153cca05a642e19d2e (diff) | |
download | wee-slack-9cddd64ae65bfcc920338a00fbfd6d49db12b456.tar.gz |
Add mpim API type for multiparty DMs
Previously MPDMs used the groups API, which worked fine except when trying to
close them. The closing events were never properly synced with Slack so the
buffers would always reappear after restarting WeeChat. Using the mpim API
(except for info since it doesn't exist: https://api.slack.com/methods#mpim)
seems to fix that.
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2ac50c0..1e25626 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -51,6 +51,13 @@ SLACK_API_TRANSLATOR = { "leave": "im.close", "mark": "im.mark", }, + "mpim": { + "history": "mpim.history", + "join": "mpim.open", + "leave": "mpim.close", + "mark": "mpim.mark", + "info": "groups.info", + }, "group": { "history": "groups.history", "join": "channels.join", @@ -1668,7 +1675,7 @@ class SlackMPDMChannel(SlackChannel): super(SlackMPDMChannel, self).__init__(eventrouter, **kwargs) n = kwargs.get('name') self.set_name(n) - self.type = "group" + self.type = "mpim" def open(self, update_remote=False): self.create_buffer() @@ -2155,6 +2162,10 @@ def handle_imhistory(message_json, eventrouter, **kwargs): handle_history(message_json, eventrouter, **kwargs) +def handle_mpimhistory(message_json, eventrouter, **kwargs): + handle_history(message_json, eventrouter, **kwargs) + + def handle_history(message_json, eventrouter, **kwargs): request_metadata = pickle.loads(message_json["wee_slack_request_metadata"]) kwargs['team'] = eventrouter.teams[request_metadata.team_hash] @@ -2454,6 +2465,10 @@ def process_im_open(message_json, eventrouter, **kwargs): w.buffer_set(channel.channel_buffer, "hotlist", "2") +def process_mpim_open(message_json, eventrouter, **kwargs): + process_im_open(message_json, eventrouter, **kwargs) + + def process_im_close(message_json, eventrouter, **kwargs): item = message_json cbuf = kwargs['team'].channels[item["channel"]].channel_buffer |