Repository: ansible-collections/community.general

Issue:
Slack Fails with Invalid Token
##### SUMMARY

When using a slack bot token that is in the format `xoxb-123675796721-71246781917-afhjal7126sjfa7a` the validation fails with the message:

```
TASK [TASK 25: WRITE OUTPUT TO SLACK] ***********************************************************************************************************************
fatal: [host]: FAILED! => changed=false 
  msg: Slack has updated its webhook API.  You need to specify a token of the form XXXX/YYYY/ZZZZ in your playbook
```

Documentation indicates that the xox* format is OK

##### ISSUE TYPE

- Bug Report

##### COMPONENT NAME

community.general.slack

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes -->
```paste below
ansible 2.9.12
  config file = /Users/joshvanderaa/projects/ansible.cfg
  configured module search path = ['/Users/joshvanderaa/projects/plugins/modules']
  ansible python module location = /Users/joshvanderaa/.local/lib/python3.7/site-packages/ansible
  executable location = /Users/joshvanderaa/.pyenv/versions/3.7.7/bin/ansible
  python version = 3.7.7 (default, Jul 25 2020, 20:25:45) [Clang 11.0.0 (clang-1100.0.33.16)]
```

##### CONFIGURATION
<!--- Paste verbatim output from "ansible-config dump --only-changed" between quotes -->
```paste below

```

##### OS / ENVIRONMENT
<!--- Provide all relevant information below, e.g. target OS versions, network device firmware, etc. -->
Slack Post

##### STEPS TO REPRODUCE
<!--- Describe exactly how to reproduce the problem, using a minimal test-case -->
1. Create a Playbook using the community.general.slack plugin
2. Setup environment variable with the token
3. Execute playbook

<!--- Paste example playbooks or commands between quotes below -->
```yaml
        - name: "TASK 25: WRITE OUTPUT TO SLACK"
          community.general.slack:
            channel: "#{{ CHANNEL_NAME }}"
            token: "{{ lookup('env', 'SLACK_API_TOKEN') }}"
            msg: "{{ msg_to_slack }}"
          delegate_to: localhost
```


##### EXPECTED RESULTS
<!--- Describe what you expected to happen when running the steps above -->
Expected post to slack

##### ACTUAL RESULTS
<!--- Describe what actually happened. If possible run with extra verbosity (-vvvv) -->
Error that the token is invalid

### Issue

The regex search to validate the token format is short by one \w+ for my particular token. 

Proposal: Move the additional validation to be `^xox[abp]-\S+$` instead of `^xox[abp]-\w+-\w+$`



Discussion:
Files identified in the description:
None

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->

Resolving patch:
diff --git a/plugins/modules/notification/slack.py b/plugins/modules/notification/slack.py
--- a/plugins/modules/notification/slack.py
+++ b/plugins/modules/notification/slack.py
@@ -314,7 +314,7 @@ def do_notify_slack(module, domain, token, payload):
     if token.count('/') >= 2:
         # New style webhook token
         slack_uri = SLACK_INCOMING_WEBHOOK % (token)
-    elif re.match(r'^xox[abp]-\w+-\w+$', token):
+    elif re.match(r'^xox[abp]-\S+$', token):
         slack_uri = SLACK_POSTMESSAGE_WEBAPI
         use_webapi = True
     else:


Test patch: