diff --git a/apprise/plugins/NotifySlack.py b/apprise/plugins/NotifySlack.py index 1a437ffa..929558f2 100644 --- a/apprise/plugins/NotifySlack.py +++ b/apprise/plugins/NotifySlack.py @@ -354,6 +354,13 @@ class NotifySlack(NotifyBase): r'>': '>', } + # To notify a channel, one uses + self._re_channel_support = re.compile( + r'(?P(?:<|\<)?[ \t]*' + r'!(?P[^| \n]+)' + r'(?:[ \t]*\|[ \t]*(?:(?P[^\n]+?)[ \t]*)?(?:>|\>)' + r'|(?:>|\>)))', re.IGNORECASE) + # The markdown in slack isn't [desc](url), it's # # To accomodate this, we need to ensure we don't escape URLs that match @@ -455,6 +462,21 @@ class NotifySlack(NotifyBase): lambda x: self._re_formatting_map[x.group()], body, ) + # Support , entries + for match in self._re_channel_support.findall(body): + # Swap back any ampersands previously updaated + channel = match[1].strip() + desc = match[2].strip() + + # Update our string + body = re.sub( + re.escape(match[0]), + ''.format( + channel=channel, desc=desc) + if desc else ''.format(channel=channel), + body, + re.IGNORECASE) + # Support , entries for match in self._re_url_support.findall(body): # Swap back any ampersands previously updaated diff --git a/test/test_plugin_slack.py b/test/test_plugin_slack.py index 20718c73..fc6ba7e2 100644 --- a/test/test_plugin_slack.py +++ b/test/test_plugin_slack.py @@ -680,6 +680,10 @@ def test_plugin_slack_markdown(mock_get, mock_post): . We also want to be able to support links without the description. + + Channel Testing + + """) # Send our notification @@ -700,4 +704,5 @@ def test_plugin_slack_markdown(mock_get, mock_post): "of it's\nmarkdown.\n\nThis one has arguments we want to preserve:"\ "\n .\n"\ "We also want to be able to support "\ - "links without the\ndescription." + "links without the\ndescription."\ + "\n\nChannel Testing\n\n"