aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorBryan Gilbert <gilbertw1@gmail.com>2017-07-16 20:59:58 -0400
committerBryan Gilbert <gilbertw1@gmail.com>2017-07-16 21:06:09 -0400
commit6718e2f88a9f9153b2b125ce9ec7c097a8d1ad61 (patch)
treed5e88802d62e80702f934c325e8a03991d48a2e7 /wee_slack.py
parentac47c2e1ac4a80b4d6a01d1f7ab0659d3d538518 (diff)
downloadwee-slack-6718e2f88a9f9153b2b125ce9ec7c097a8d1ad61.tar.gz
call channel info on channel open to set unread count and update hotlist
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py39
1 files changed, 20 insertions, 19 deletions
diff --git a/wee_slack.py b/wee_slack.py
index bf45ffc..367899c 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1111,6 +1111,7 @@ class SlackChannel(object):
# short name relates to the localvar we change for typing indication
self.current_short_name = self.name
self.update_nicklist()
+ self.unread_count_display = 0
def __eq__(self, compare_str):
if compare_str == self.slack_name or compare_str == self.formatted_name() or compare_str == self.formatted_name(style="long_default"):
@@ -1136,6 +1137,14 @@ class SlackChannel(object):
return True
return False
+ def set_unread_count_display(self, count):
+ self.unread_count_display = count
+ if (self.unread_count_display > 0):
+ if self.type == "im":
+ w.buffer_set(self.channel_buffer, "hotlist", "2")
+ else:
+ w.buffer_set(self.channel_buffer, "hotlist", "1")
+
def formatted_name(self, style="default", typing=False, **kwargs):
if config.channel_name_typing_indicator:
if not typing:
@@ -1174,9 +1183,6 @@ class SlackChannel(object):
self.create_buffer()
self.active = True
self.get_history()
- if "info" in SLACK_API_TRANSLATOR[self.type]:
- s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["info"], {"name": self.identifier}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
- self.eventrouter.receive(s)
# self.create_buffer()
def check_should_open(self, force=False):
@@ -1231,22 +1237,10 @@ class SlackChannel(object):
w.buffer_set(self.channel_buffer, "localvar_set_server", self.team.preferred_name)
# else:
# self.eventrouter.weechat_controller.register_buffer(self.channel_buffer, self)
- try:
- for c in range(self.unread_count_display):
- if self.type == "im":
- w.buffer_set(self.channel_buffer, "hotlist", "2")
- else:
- w.buffer_set(self.channel_buffer, "hotlist", "1")
- else:
- pass
- # dbg("no unread in {}".format(self.name))
- except:
- pass
- self.update_nicklist()
- # dbg("exception no unread count")
- # if self.unread_count != 0 and not self.muted:
- # w.buffer_set(self.channel_buffer, "hotlist", "1")
+ if "info" in SLACK_API_TRANSLATOR[self.type]:
+ s = SlackRequest(self.team.token, SLACK_API_TRANSLATOR[self.type]["info"], {"channel": self.identifier}, team_hash=self.team.team_hash, channel_identifier=self.identifier)
+ self.eventrouter.receive(s)
def destroy_buffer(self, update_remote):
if self.channel_buffer is not None:
@@ -2085,7 +2079,14 @@ def handle_rtmstart(login_data, eventrouter):
# self.identifier = self.domain
-
+def handle_channelsinfo(channel_json, eventrouter, **kwargs):
+ unread_count_display = channel_json['channel']['unread_count_display']
+ channel_id = channel_json['channel']['id']
+ request_metadata = pickle.loads(channel_json["wee_slack_request_metadata"])
+ team = eventrouter.teams[request_metadata.team_hash]
+ channel = team.channels[channel_id]
+ channel.set_unread_count_display(unread_count_display)
+
def handle_groupshistory(message_json, eventrouter, **kwargs):
handle_history(message_json, eventrouter, **kwargs)