diff options
author | Ryan Huber <rhuber@gmail.com> | 2015-07-06 15:28:52 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2015-07-06 15:28:52 -0700 |
commit | 4a4e11200f7317a03523e412ccc1426248218a4e (patch) | |
tree | ffc82ddd79a41438502577d75551b3ffc01059fd | |
parent | 4d79984ee9f6d5fa44b782b86fb48aa062713a01 (diff) | |
parent | cf79907a92dbfbc752d32a4b12f180106835075a (diff) | |
download | wee-slack-4a4e11200f7317a03523e412ccc1426248218a4e.tar.gz |
Merge pull request #88 from tfheen/ignore_deleted_users
Ignore deleted users when constructing nick list
-rw-r--r-- | wee_slack.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/wee_slack.py b/wee_slack.py index a88c9b3..78ed425 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -297,7 +297,7 @@ class SlackServer(object): def create_slack_mappings(self, data): for item in data["users"]: - self.users.append(User(self, item["name"], item["id"], item["presence"])) + self.users.append(User(self, item["name"], item["id"], item["presence"], item["deleted"])) for item in data["channels"]: if "last_read" not in item: @@ -424,12 +424,14 @@ class Channel(SlackThing): try: for user in self.members: user = self.server.users.find(user) + if user.deleted: + continue if user.presence == 'away': w.nicklist_add_nick(self.channel_buffer, "", user.name, user.color_name, " ", "", 1) else: w.nicklist_add_nick(self.channel_buffer, "", user.name, user.color_name, "+", "", 1) - except: - print "DEBUG: {} {}".format(self.identifier,self.name) + except Exception as e: + print "DEBUG: {} {} {}".format(self.identifier, self.name, e) def fullname(self): return "{}.{}".format(self.server.domain, self.name) @@ -666,9 +668,10 @@ class DmChannel(Channel): class User(SlackThing): - def __init__(self, server, name, identifier, presence="away"): + def __init__(self, server, name, identifier, presence="away", deleted=False): super(User, self).__init__(name, identifier) self.channel_buffer = w.info_get("irc_buffer", "{}.{}".format(domain, self.name)) + self.deleted = deleted self.presence = presence self.server = server self.update_color() @@ -1124,6 +1127,7 @@ def process_channel_leave(message_json): def process_channel_archive(message_json): + server = servers.find(message_json["myserver"]) channel = server.channels.find(message_json["channel"]) channel.detach_buffer() @@ -1178,7 +1182,10 @@ def process_im_created(message_json): def process_user_typing(message_json): server = servers.find(message_json["myserver"]) - server.channels.find(message_json["channel"]).set_typing(server.users.find(message_json["user"]).name) + channel = server.channels.find(message_json["channel"]) + if channel: + channel.set_typing(server.users.find(message_json["user"]).name) + # todo: does this work? |