mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Slack: Add support for (some) groups (#5019)
* Slack: Add support for (some) groups Some of the older private channels in the workspace I'm working in have channel ID's starting with `G0` and `GF` and this resulted to false positive `channel_not_found` errors. I've added these prefixes to the list to maintain as much backwards compatibility as possible. Ideally the auto-prefix of the channel name with `#` is dropped entirely, given the Channel ID's have become more dominant in the Slack API over the past years. * Add changelog fragment for slack channel prefix fix * Update changelogs/fragments/5019-slack-support-more-groups.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
74f2e1d28b
commit
3fe9592cf1
2 changed files with 3 additions and 1 deletions
2
changelogs/fragments/5019-slack-support-more-groups.yml
Normal file
2
changelogs/fragments/5019-slack-support-more-groups.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- slack - fix incorrect channel prefix ``#`` caused by incomplete pattern detection by adding ``G0`` and ``GF`` as channel ID patterns (https://github.com/ansible-collections/community.general/pull/5019).
|
|
@ -293,7 +293,7 @@ def build_payload_for_slack(text, channel, thread_id, username, icon_url, icon_e
|
||||||
# With a custom color we have to set the message as attachment, and explicitly turn markdown parsing on for it.
|
# With a custom color we have to set the message as attachment, and explicitly turn markdown parsing on for it.
|
||||||
payload = dict(attachments=[dict(text=escape_quotes(text), color=color, mrkdwn_in=["text"])])
|
payload = dict(attachments=[dict(text=escape_quotes(text), color=color, mrkdwn_in=["text"])])
|
||||||
if channel is not None:
|
if channel is not None:
|
||||||
if channel.startswith(('#', '@', 'C0')):
|
if channel.startswith(('#', '@', 'C0', 'GF', 'G0')):
|
||||||
payload['channel'] = channel
|
payload['channel'] = channel
|
||||||
else:
|
else:
|
||||||
payload['channel'] = '#' + channel
|
payload['channel'] = '#' + channel
|
||||||
|
|
Loading…
Reference in a new issue