aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authormelanie witt <melwittt@gmail.com>2023-09-22 02:09:53 -0700
committerGitHub <noreply@github.com>2023-09-22 11:09:53 +0200
commit2050552f6aed3525e2c32e70b40c7ba64c6eb103 (patch)
treea23d9f343852cbf154e47c1290ccbdac7eead62d /wee_slack.py
parentc303a77c5420f2f97306802953d57a9587ba5fd6 (diff)
downloadwee-slack-2050552f6aed3525e2c32e70b40c7ba64c6eb103.tar.gz
Make render_emoji_as_string = "both" work with rich_text blocks (#902)
Commit 74da30342e8d328fc085d2158e37afda3b908f2c added support for using rich_text blocks to format messages. With this change, the use of replace_string_with_emoji() for text type "emoji" can result in running the replacement twice as replace_string_with_emoji() is also called as one of the last steps in SlackMessage.render(). This works fine in the default case when render_emoji_as_string = "", however render_emoji_as_string = "both" results in output like: πŸ˜„ (πŸ˜„ (:smile:)) instead of the intended: πŸ˜„ (:smile:) This excludes blocks rendered earlier in the method from the second call of replace_string_with_emoji().
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 84c437f..56944f8 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3443,7 +3443,10 @@ class SlackMessage(object):
),
)
- text = replace_string_with_emoji(text)
+ # replace_string_with_emoji() was called on blocks earlier via
+ # unfurl_blocks(), so exclude them here
+ text_to_replace = text[len(blocks_rendered) :]
+ text = text[: len(blocks_rendered)] + replace_string_with_emoji(text_to_replace)
self.message_json["_rendered_text"] = text
return text