flask-slack-template
A light decorator around flask and slack to remove the boilerplate for handling Slack slash commands
Example Usage:
from flask import Flask
from flaskslack.flaskslack import FlaskSlack
from flaskslack.slack import ResponseType, Slack
app = Flask(__name__)
# If you want to get your config in a non default way,
# you can create a slack client with: Slack('slack_oauth_token', 'slack_signing_secret')
slack = Slack.create()
flask_slack = FlaskSlack(app, slack)
# set verify_signature to False if you want to do some local testing
@flask_slack.slack_route('/slack/endpoint', response_type=ResponseType.IN_CHANNEL, verify_signature=True)
def get_channel_member_ids(form_content):
"""
:param form_content: a dict containing the data payload from the slack HTTP POST
see: https://api.slack.com/slash-commands#app_command_handling
:return: It should return a dict. The dict should contain a 'text' field, and/or a list of 'attachments'.
see: https://api.slack.com/slash-commands#responding_immediate_response
"""
channel_id = form_content["channel_id"]
members_form_content = slack.try_api_call("conversations.members", channel=channel_id)
channel_member_ids = members_form_content["members"]
text_response = f"The channel_member_ids for channel_id {channel_id} is: {channel_member_ids}"
return Slack.create_response(text_response)
if __name__ == "__main__":
app.run(host="localhost")
Installation:
pip install flask_slack_template- Create a file called
config.jsonin the root directory with the slack oauth token and signing secret{ "SLACK_OAUTH_TOKEN": "YOUR_TOKEN_HERE", "SLACK_SIGNING_SECRET": "YOUR_SECRET_HERE" }
# main.py slack = Slack.create() # If you want to get your config in a non default way, # you can create a slack client with: Slack('slack_oauth_token', 'slack_signing_secret') # slack = Slack('slack_oauth_token', 'slack_signing_secret')
- You can find your oauth token and signing secret here
Metadata
Release files for flask-slack-template 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_slack_template-0.0.7.tar.gz | 5.4 kB | Without provenance | Details for flask_slack_template-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_slack_template-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for flask_slack_template-0.0.7-py3-none-any.whl |
Total release size: 12.9 kB
Release files / flask_slack_template-0.0.7.tar.gz
| Download URL | flask_slack_template-0.0.7.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87e85b329c661e78464edd810ec1ce80e76df7397f6af546f858de2f1964409a
|
|
BLAKE2b-256 checksum How to use checksums |
e854462bad57429ed64c4af31525c5b4a8a2757e9e17761751a418a712bd7e63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Release files / flask_slack_template-0.0.7-py3-none-any.whl
| Download URL | flask_slack_template-0.0.7-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80772914b497a28a60b20226b6e01748cb9a64d60fc4544af7a68ed0130fedfd
|
|
BLAKE2b-256 checksum How to use checksums |
35c3a6b3e4e86679aee4ad6d43245b9fca70a2fcaa9bb70360b6b43110886758
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4
|
Security for flask-slack-template 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.