From 8a39c761289af6db487178c8bc1a4b1b7216d748 Mon Sep 17 00:00:00 2001 From: Marcel de Vries Date: Sun, 23 Jul 2017 20:35:20 +0200 Subject: Update nicklist when team member presence changes --- wee_slack.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wee_slack.py b/wee_slack.py index 7014071..d92bff5 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2151,7 +2151,15 @@ def process_manual_presence_change(message_json, eventrouter, **kwargs): def process_presence_change(message_json, eventrouter, **kwargs): - kwargs["user"].presence = message_json["presence"] + if "user" in kwargs: + user = kwargs["user"] + team = kwargs["team"] + user.presence = message_json["presence"] + + for c in team.channels: + c = team.channels[c] + if user.id in c.members: + c.update_nicklist(user.id) def process_pref_change(message_json, eventrouter, **kwargs): -- cgit From 59856162998c58fa7e0a2bceb594f7fd2d307ea3 Mon Sep 17 00:00:00 2001 From: Marcel de Vries Date: Mon, 24 Jul 2017 19:52:46 +0200 Subject: Move presence change to a SlackTeam method --- wee_slack.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index d92bff5..4d78fc2 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1081,6 +1081,14 @@ class SlackTeam(object): dbg("Unexpected error: {}\nSent: {}".format(sys.exc_info()[0], data)) self.set_connected() + def update_member_presence(self, user, presence): + user.presence = presence + + for c in self.channels: + c = self.channels[c] + if user.id in c.members: + c.update_nicklist(user.id) + class SlackChannel(object): """ @@ -2154,12 +2162,7 @@ def process_presence_change(message_json, eventrouter, **kwargs): if "user" in kwargs: user = kwargs["user"] team = kwargs["team"] - user.presence = message_json["presence"] - - for c in team.channels: - c = team.channels[c] - if user.id in c.members: - c.update_nicklist(user.id) + team.update_member_presence(user, message_json["presence"]) def process_pref_change(message_json, eventrouter, **kwargs): -- cgit