From c0abd821737886ae6b6eb027c1ac08b0e31f125b Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 11 Feb 2020 00:31:26 +0100 Subject: Move inviter text to before blocks and unfurl_refs Blocks should come after the inviter text, and by moving it before unfurl_refs we don't have to call that twice. --- wee_slack.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index bfa6ff6..2c5b165 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2406,6 +2406,11 @@ class SlackMessage(object): if self.message_json.get('mrkdwn', True): text = render_formatting(text) + if (self.message_json.get('subtype') in ('channel_join', 'group_join') and + self.message_json.get('inviter')): + inviter_id = self.message_json.get('inviter') + text += " by invitation from <@{}>".format(inviter_id) + if "blocks" in self.message_json: text += unfurl_blocks(self.message_json) @@ -2415,12 +2420,6 @@ class SlackMessage(object): not self.message_json['text'].startswith(self.sender)): text = "{} {}".format(self.sender, text) - if (self.message_json.get('subtype') in ('channel_join', 'group_join') and - self.message_json.get('inviter')): - inviter_id = self.message_json.get('inviter') - inviter_nick = unfurl_refs("<@{}>".format(inviter_id)) - text += " by invitation from {}".format(inviter_nick) - if "edited" in self.message_json: text += " " + colorize_string(config.color_edited_suffix, '(edited)') -- cgit