From de5d7818e61f240be5faa5482059e36d7fdc3cb0 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 14 Jun 2020 00:26:38 +0200 Subject: Refactor to if/else for SlackThreadChannel.formatted_name --- wee_slack.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index e5620ac..2f75b52 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2468,12 +2468,14 @@ class SlackThreadChannel(SlackChannelCommon): def formatted_name(self, style="default"): thread_hash = self.parent_message.hash - styles = { - "default": "{}.{}".format(self.parent_channel.formatted_name(), thread_hash), - "long_default": "{}.{}".format(self.parent_channel.formatted_name(style="long_default"), thread_hash), - "sidebar": " +{}".format(self.label or thread_hash), - } - return styles[style] + if style == "sidebar": + return " +{}".format(self.label or thread_hash) + elif style == "long_default": + channel_name = self.parent_channel.formatted_name(style="long_default") + return "{}.{}".format(channel_name, thread_hash) + else: + channel_name = self.parent_channel.formatted_name() + return "{}.{}".format(channel_name, thread_hash) def mark_read(self, ts=None, update_remote=True, force=False, post_data={}): if not self.parent_message.subscribed: -- cgit