aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorEric Wang <gnawrice@gmail.com>2017-10-16 15:30:04 -0700
committerEric Wang <gnawrice@gmail.com>2017-10-16 15:33:58 -0700
commit27153da2d7d3037d348367a250588ee09701f502 (patch)
treec2ee5e471bd3bd0531d1eac0c20ed9e343cb0d0c /wee_slack.py
parent9cddd64ae65bfcc920338a00fbfd6d49db12b456 (diff)
downloadwee-slack-27153da2d7d3037d348367a250588ee09701f502.tar.gz
Use Conversations API for join/open and leave/close methods
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py34
1 files changed, 15 insertions, 19 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 1e25626..b6f943a 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -40,28 +40,28 @@ RECORD_DIR = "/tmp/weeslack-debug"
SLACK_API_TRANSLATOR = {
"channel": {
"history": "channels.history",
- "join": "channels.join",
- "leave": "channels.leave",
+ "join": "conversations.join",
+ "leave": "conversations.leave",
"mark": "channels.mark",
"info": "channels.info",
},
"im": {
"history": "im.history",
- "join": "im.open",
- "leave": "im.close",
+ "join": "conversations.open",
+ "leave": "conversations.close",
"mark": "im.mark",
},
"mpim": {
"history": "mpim.history",
- "join": "mpim.open",
- "leave": "mpim.close",
+ "join": "conversations.open",
+ "leave": "conversations.close",
"mark": "mpim.mark",
"info": "groups.info",
},
"group": {
"history": "groups.history",
- "join": "channels.join",
- "leave": "groups.leave",
+ "join": "conversations.join",
+ "leave": "conversations.leave",
"mark": "groups.mark",
"info": "groups.info"
},
@@ -1293,7 +1293,7 @@ class SlackChannel(object):
if self.type == "im":
if "join" in SLACK_API_TRANSLATOR[self.type]:
- s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["join"], {"user": self.user, "return_im": True}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
+ s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["join"], {"users": self.user, "return_im": True}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
self.eventrouter.receive(s)
def destroy_buffer(self, update_remote):
@@ -1631,7 +1631,7 @@ class SlackDMChannel(SlackChannel):
self.eventrouter.receive(s)
if update_remote:
if "join" in SLACK_API_TRANSLATOR[self.type]:
- s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["join"], {"user": self.user, "return_im": True}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
+ s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["join"], {"users": self.user, "return_im": True}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
self.eventrouter.receive(s)
self.create_buffer()
@@ -2143,12 +2143,12 @@ def handle_groupsinfo(group_json, eventrouter, **kwargs):
group_id = group_json['group']['id']
group.set_unread_count_display(unread_count_display)
-def handle_imopen(im_json, eventrouter, **kwargs):
- request_metadata = pickle.loads(im_json["wee_slack_request_metadata"])
+def handle_conversationsopen(conversation_json, eventrouter, **kwargs):
+ request_metadata = pickle.loads(conversation_json["wee_slack_request_metadata"])
team = eventrouter.teams[request_metadata.team_hash]
- im = team.channels[request_metadata.channel_identifier]
- unread_count_display = im_json['channel']['unread_count_display']
- im.set_unread_count_display(unread_count_display)
+ conversation = team.channels[request_metadata.channel_identifier]
+ unread_count_display = conversation_json['channel']['unread_count_display']
+ conversation.set_unread_count_display(unread_count_display)
def handle_groupshistory(message_json, eventrouter, **kwargs):
handle_history(message_json, eventrouter, **kwargs)
@@ -2465,10 +2465,6 @@ 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