From 7ca433bfc981fdbd4cf54e79f1ecf9dec7bcd867 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Tue, 22 Dec 2015 20:53:37 -0800 Subject: Add mpdm channel This adds a new channel type for mpdms which formats as "#first,second,third" This includes the current user's username, which we may want to exclude. --- wee_slack.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wee_slack.py b/wee_slack.py index c8d24ee..44ae072 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -291,7 +291,10 @@ class SlackServer(object): if "last_read" not in item: item["last_read"] = 0 if not item["is_archived"]: - self.add_channel(GroupChannel(self, item["name"], item["id"], item["is_open"], item["last_read"], "#", item["members"], item["topic"]["value"])) + if item["name"].startswith("mpdm-"): + self.add_channel(MpdmChannel(self, item["name"], item["id"], item["is_open"], item["last_read"], "#", item["members"], item["topic"]["value"])) + else: + self.add_channel(GroupChannel(self, item["name"], item["id"], item["is_open"], item["last_read"], "#", item["members"], item["topic"]["value"])) for item in data["ims"]: if "last_read" not in item: item["last_read"] = 0 @@ -723,6 +726,12 @@ class GroupChannel(Channel): super(GroupChannel, self).__init__(server, name, identifier, active, last_read, prepend_name, members, topic) self.type = "group" +class MpdmChannel(Channel): + + def __init__(self, server, name, identifier, active, last_read=0, prepend_name="", members=[], topic=""): + name = ",".join("-".join(name.split("-")[1:-1]).split("--")) + super(MpdmChannel, self).__init__(server, name, identifier, active, last_read, prepend_name, members, topic) + self.type = "group" class DmChannel(Channel): -- cgit