diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-19 15:11:56 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-06-20 23:55:54 +0200 |
commit | 53f3ce925188294422adbe16bf605bd26de37e3d (patch) | |
tree | 5108c3589c41051c6e613f6a6c4923a6780f92bc /wee_slack.py | |
parent | b418f492c081c58a89dc06d91159948b41915b82 (diff) | |
download | wee-slack-53f3ce925188294422adbe16bf605bd26de37e3d.tar.gz |
Combine channel formatted_name methods
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 80 |
1 files changed, 22 insertions, 58 deletions
diff --git a/wee_slack.py b/wee_slack.py index 06f225e..b615545 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1827,19 +1827,40 @@ class SlackChannel(SlackChannelCommon): prepend = config.group_name_prefix elif self.type == "shared": prepend = config.shared_name_prefix + elif self.type == "im": + if style != "sidebar": + prepend = "" + elif present and config.show_buflist_presence: + prepend = "+" + elif config.channel_name_typing_indicator or config.show_buflist_presence: + prepend = " " + else: + prepend = "" + elif self.type == "mpim": + if style == "sidebar": + prepend = "@" + else: + prepend = "" else: prepend = "#" name = self.label_full or self.slack_name if style == "sidebar": - sidebar_color = config.color_buflist_muted_channels if self.muted else "" name = self.label_short or name if self.label_short_drop_prefix: if show_typing: name = prepend + name[1:] else: name = prepend + name + + if self.muted: + sidebar_color = config.color_buflist_muted_channels + elif self.type == "im" and config.colorize_private_chats: + sidebar_color = self.color_name + else: + sidebar_color = "" + return colorize_string(sidebar_color, name) elif style == "long_default": if self.label_full_drop_prefix: @@ -2311,38 +2332,6 @@ class SlackDMChannel(SlackChannel): else: self.color_name = "" - def formatted_name(self, style="default", typing=False, present=True): - show_typing = typing and config.channel_name_typing_indicator - name = self.label_full or self.slack_name - if style == "sidebar": - name = self.label_short or name - if show_typing: - prepend = ">" - elif present and config.show_buflist_presence: - prepend = "+" - elif config.channel_name_typing_indicator or config.show_buflist_presence: - prepend = " " - else: - prepend = "" - - if self.label_short_drop_prefix: - if show_typing: - name = prepend + name[1:] - else: - name = prepend + name - - if config.colorize_private_chats: - return colorize_string(self.color_name, name) - else: - return name - elif style == "long_default": - if self.label_full_drop_prefix: - return name - else: - return "{}.{}".format(self.team.name, name) - else: - return name - def open(self, update_remote=True): self.create_buffer() self.get_history() @@ -2412,31 +2401,6 @@ class SlackMPDMChannel(SlackChannel): s = SlackRequest(self.team, join_method, {'users': ','.join(self.members)}, channel=self) self.eventrouter.receive(s) - def formatted_name(self, style="default", typing=False, present=None): - show_typing = typing and config.channel_name_typing_indicator - name = self.label_full or self.slack_name - if style == "sidebar": - name = self.label_short or name - if show_typing: - prepend = ">" - else: - prepend = "@" - - if self.label_short_drop_prefix: - if show_typing: - return prepend + name[1:] - else: - return name - else: - return prepend + name - elif style == "long_default": - if self.label_full_drop_prefix: - return name - else: - return "{}.{}".format(self.team.name, name) - else: - return name - class SlackSharedChannel(SlackChannel): def __init__(self, eventrouter, **kwargs): |