diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..4a08579 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,12 @@ +# Salesforce Open Source project configuration +# Learn more: https://github.com/salesforce/oss-template +#ECCN:Open Source +#GUSINFO:Open Source,Open Source Workflow + +# @slackapi/slack-platform-python +# are code reviewers for all changes in this repo. +* @slackapi/slack-platform-python + +# @slackapi/developer-education +# are code reviewers for changes in the `/docs` directory. +/docs/ @slackapi/developer-education diff --git a/.github/contributing.md b/.github/contributing.md index bff12fc..3da03c0 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -41,9 +41,9 @@ For your contribution to be accepted: - [x] Commits should be atomic and messages must be descriptive. Related issues should be mentioned by Issue number. If the contribution doesn't meet the above criteria, a maintainer should discuss it with you. You can -continue improve a Pull Request by adding commits to the branch from which the PR was created. +continue to improve a Pull Request by adding commits to the branch from which the PR was created. -[Interested in knowing more about about pull requests at Slack?](https://slack.engineering/on-empathy-pull-requests-979e4257d158#.awxtvmb2z) +[Interested in knowing more about pull requests at Slack?](https://slack.engineering/on-empathy-pull-requests-979e4257d158#.awxtvmb2z) ## Creating a Pull Request @@ -53,5 +53,5 @@ continue improve a Pull Request by adding commits to the branch from which the P 3. :herb: Create a new branch and check it out. 4. :crystal_ball: Make your changes and commit them locally. Magic happens here! 5. :arrow_heading_up: Push your new branch to your fork. (e.g. `git push username fix-issue-16`). -6. :inbox_tray: Open a Pull Request on github.com from your new branch on your fork to `master` in this +6. :inbox_tray: Open a Pull Request on github.com from your new branch on your fork to `main` (`v2` for 2.x series updates) in this repository. diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..c17e84e --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,49 @@ +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions +name: CI Build + +on: + push: + branches: + - main + - v2 + pull_request: + +jobs: + build: + runs-on: ubuntu-22.04 + timeout-minutes: 5 + strategy: + matrix: + python-version: + - "3.13" + - "3.12" + - "3.11" + - "3.10" + - "3.9" + - "3.8" + - "3.7" + permissions: + contents: read + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install -U pip + pip install -e . + pip install -r requirements-dev.txt + - name: Run all tests + run: | + python_version=`python -V` + if [ ${python_version:7:3} == "3.12" ]; then + pip install -U flake8 + flake8 slackeventsapi + pytest --cov-report= --cov=slackeventsapi tests && bash <(curl -s https://codecov.io/bash) + else + pytest tests + fi diff --git a/.github/workflows/triage-issues.yml b/.github/workflows/triage-issues.yml new file mode 100644 index 0000000..6a50498 --- /dev/null +++ b/.github/workflows/triage-issues.yml @@ -0,0 +1,32 @@ +# This workflow uses the following github action to automate +# management of stale issues and prs in this repo: +# https://github.com/marketplace/actions/close-stale-issues + +name: Close stale issues and PRs + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * 0" + +jobs: + stale: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@cdf15f641adb27a71842045a94023bef6945e3aa # v4.0.0 + with: + days-before-issue-stale: 30 + days-before-issue-close: 10 + days-before-pr-stale: -1 + days-before-pr-close: -1 + stale-issue-label: auto-triage-stale + stale-issue-message: 👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. + close-issue-message: As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number. + exempt-issue-labels: auto-triage-skip,bug,discussion,docs,enhancement,security,tests + exempt-all-milestones: true + remove-stale-when-updated: true + enable-statistics: true + operations-per-run: 60 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 301e047..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -dist: xenial -language: python -python: - - "2.7" - - "3.5" - - "3.6" - - "3.7" - - "3.8" -install: - - pip install -U pip pytest # python 2.7 requires pytest 4 - - python setup.py install - - pip install flake8 - - pip install -r requirements-dev.txt -script: - - flake8 slackeventsapi - - pytest --cov-report= --cov=slackeventsapi tests -after_success: - - codecov -e $TRAVIS_PYTHON_VERSION diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 64e10db..f767c8f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,22 @@ Changelog ============ +v3.0.0 (2021-09-08) +--------------------- + +https://github.com/slackapi/python-slack-events-api/milestone/3?closed=1 + +- Updates for Flask 2.x compatibility - thanks @antonio-te @seratch + +Migration guide: + +Since this version, this package no longer works with: + +- Python 2.7 +- Flask 1.x + +Please use Python 3.6 or higher along with Flask 2.x. + v2.2.1 (2020-07-28) --------------------- diff --git a/LICENSE b/LICENSE index 73da6e9..a638457 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2016 Slack Technologies, Inc +Copyright (c) 2015- Slack Technologies, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index 82c419b..707c5ae 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,8 @@ Slack Events API adapter for Python .. image:: https://badge.fury.io/py/slackeventsapi.svg :target: https://pypi.org/project/slackeventsapi/ -.. image:: https://travis-ci.org/slackapi/python-slack-events-api.svg?branch=main - :target: https://travis-ci.org/slackapi/python-slack-events-api +.. image:: https://github.com/slackapi/python-slack-events-api/actions/workflows/ci-build.yml/badge.svg + :target: https://github.com/slackapi/python-slack-events-api/actions/workflows/ci-build.yml .. image:: https://codecov.io/gh/slackapi/python-slack-events-api/branch/main/graph/badge.svg :target: https://codecov.io/gh/slackapi/python-slack-events-api diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..b69c021 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +## Security + +Please report any security issue to [https://www.sfdc.co/SubmitVuln](https://www.sfdc.co/SubmitVuln) +as soon as it is discovered. This library limits its runtime dependencies in +order to reduce the total cost of ownership as much as can be, but all consumers +should remain vigilant and have their security stakeholders review all third-party +products (3PP) like this one and their dependencies. diff --git a/example/README.rst b/example/README.rst index f97eeb2..c57e59e 100644 --- a/example/README.rst +++ b/example/README.rst @@ -16,13 +16,13 @@ We're using venv (or virtualenv) to keep the dependencies and environmental vari .. code:: - python -m venv env + python -m venv .venv Then initialize the virtualenv: .. code:: - source env/bin/activate + source .venv/bin/activate **Install the app's dependencies:** diff --git a/example/blueprint/example.py b/example/blueprint/example.py index c2d5ca7..445fd83 100644 --- a/example/blueprint/example.py +++ b/example/blueprint/example.py @@ -1,15 +1,5 @@ -# ------------------ -# Only for running this script here -import logging -import sys -from os.path import dirname - -sys.path.insert(1, f"{dirname(__file__)}/../..") -logging.basicConfig(level=logging.DEBUG) -# ------------------ - from slackeventsapi import SlackEventAdapter -from slack import WebClient +from slack_sdk.web import WebClient import os from flask import Flask, Blueprint @@ -23,6 +13,16 @@ slack_bot_token = os.environ["SLACK_BOT_TOKEN"] slack_client = WebClient(slack_bot_token) +# Example responder to bot mentions +@slack_events_adapter.on("app_mention") +def handle_mentions(event_data): + event = event_data["event"] + slack_client.chat_postMessage( + channel=event["channel"], + text=f"You said:\n>{event['text']}", + ) + + # Example responder to greetings @slack_events_adapter.on("message") def handle_message(event_data): diff --git a/example/blueprint/requirements.txt b/example/blueprint/requirements.txt index 0767df2..bd106ae 100644 --- a/example/blueprint/requirements.txt +++ b/example/blueprint/requirements.txt @@ -1,3 +1,3 @@ -slackclient>=2.7.1 -slackeventsapi>=2.1.0 -flask>=1 \ No newline at end of file +slack-sdk>=3,<4 +slackeventsapi>=3,<4 +flask>=2,<3 \ No newline at end of file diff --git a/example/current_app/main.py b/example/current_app/main.py index 9fcd32c..4094e08 100644 --- a/example/current_app/main.py +++ b/example/current_app/main.py @@ -1,12 +1,5 @@ -# ------------------ -# Only for running this script here -import sys -from os.path import dirname -sys.path.insert(1, f"{dirname(__file__)}/../..") -# ------------------ - import os -from slack import WebClient +from slack_sdk.web import WebClient import logging logging.basicConfig(level=logging.DEBUG) diff --git a/example/current_app/test_module/slack_app.py b/example/current_app/test_module/slack_app.py index 058f09b..3d51de2 100644 --- a/example/current_app/test_module/slack_app.py +++ b/example/current_app/test_module/slack_app.py @@ -1,13 +1,3 @@ -# ------------------ -# Only for running this script here -import logging -import sys -from os.path import dirname - -sys.path.insert(1, f"{dirname(__file__)}/../../..") -logging.basicConfig(level=logging.DEBUG) -# ------------------ - from flask import current_app as app from slackeventsapi import SlackEventAdapter import os diff --git a/example/example.py b/example/example.py index 0669b43..3d8c2d5 100644 --- a/example/example.py +++ b/example/example.py @@ -1,5 +1,5 @@ from slackeventsapi import SlackEventAdapter -from slack import WebClient +from slack_sdk.web import WebClient import os # Our app's Slack Event Adapter for receiving actions via the Events API @@ -10,6 +10,16 @@ slack_bot_token = os.environ["SLACK_BOT_TOKEN"] slack_client = WebClient(slack_bot_token) +# Example responder to bot mentions +@slack_events_adapter.on("app_mention") +def handle_mentions(event_data): + event = event_data["event"] + slack_client.chat_postMessage( + channel=event["channel"], + text=f"You said:\n>{event['text']}", + ) + + # Example responder to greetings @slack_events_adapter.on("message") def handle_message(event_data): diff --git a/example/issues/issue_49_link_shared_ampersand/example.py b/example/issues/issue_49_link_shared_ampersand/example.py index 02e8851..ac31026 100644 --- a/example/issues/issue_49_link_shared_ampersand/example.py +++ b/example/issues/issue_49_link_shared_ampersand/example.py @@ -1,13 +1,3 @@ -# ------------------ -# Only for running this script here -import logging -import sys -from os.path import dirname - -sys.path.insert(1, f"{dirname(__file__)}/../../..") -logging.basicConfig(level=logging.DEBUG) -# ------------------ - import os from slackeventsapi import SlackEventAdapter diff --git a/example/issues/issue_49_link_shared_ampersand/requirements.txt b/example/issues/issue_49_link_shared_ampersand/requirements.txt index 0767df2..bd106ae 100644 --- a/example/issues/issue_49_link_shared_ampersand/requirements.txt +++ b/example/issues/issue_49_link_shared_ampersand/requirements.txt @@ -1,3 +1,3 @@ -slackclient>=2.7.1 -slackeventsapi>=2.1.0 -flask>=1 \ No newline at end of file +slack-sdk>=3,<4 +slackeventsapi>=3,<4 +flask>=2,<3 \ No newline at end of file diff --git a/example/python2/README.rst b/example/python2/README.rst deleted file mode 100644 index 62fb216..0000000 --- a/example/python2/README.rst +++ /dev/null @@ -1,158 +0,0 @@ -Example Slack events API bot -============================= - -This example app shows how easy it is to implement the Slack Events API Adapter -to receive Slack Events and respond to -messages using Slack's Web API via python-slackclient. - -🤖 Setup and running the app ------------------------------- - -**Set up your Python environment:** - -We're using virtualenv to keep the dependencies and environmental variables specific to this app. See `virtualenv`_ docs for more info. - -.. _virtualenv: https://virtualenv.pypa.io - -This example app works best in Python 2.7. If 2.7 is your default version, create a virtual environment by running: - -.. code:: - - virtualenv env - -Otherwise, if Python 3+ is your default, specify the path to your 2.7 instance: - -.. code:: - - virtualenv -p /your/path/to/python2 env - -Then initialize the virtualenv: - -.. code:: - - source env/bin/activate - - -**Install the app's dependencies:** - -.. code:: - - pip install -r requirements.txt - -**🤖 Create a Slack app** - -Create a Slack app on https://api.slack.com/apps/ - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877733/32979776-1de5-11e7-87d4-b5dc9e3e7973.png - -**🤖 Add a bot user to your app** - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877750/47a16034-1de5-11e7-989b-2a90b9d8e7e3.png - -**🤖 Install your app on your team** - -Visit your app's **Install App** page and click **Install App to Team**. - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877770/61804c36-1de5-11e7-91ef-5cf2e0845729.png - -Authorize your app - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877792/774ed94c-1de5-11e7-8857-ac8d662c5b27.png - -**🤖 Save your app's credentials** - -Once you've authorized your app, you'll be presented with your app's tokens. - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877652/d8eebbb4-1de4-11e7-8f75-2cfb1e9d45ee.png - -Copy your app's **Bot User OAuth Access Token** and add it to your python environmental variables - -.. code:: - - export SLACK_BOT_TOKEN=xxxXXxxXXxXXxXXXXxxxX.xXxxxXxxxx - -Next, go back to your app's **Basic Information** page - -.. image:: https://user-images.githubusercontent.com/32463/43932347-63b21eca-9bf8-11e8-8b30-0a848c263bb1.png - -Add your app's **Signing Secret** to your python environmental variables - -.. code:: - - export SLACK_SIGNING_SECRET=xxxxxxxxXxxXxxXxXXXxxXxxx - - -**🤖 Start ngrok** - -In order for Slack to contact your local server, you'll need to run a tunnel. We -recommend ngrok or localtunnel. We're going to use ngrok for this example. - -If you don't have ngrok, `download it here`_. - -.. _download it here: https://ngrok.com - - -Here's a rudimentary diagream of how ngrok allows Slack to connect to your server - -.. image:: https://cloud.githubusercontent.com/assets/32463/25376866/940435fa-299d-11e7-9ee3-08d9427417f6.png - - -💡 Slack requires event requests be delivered over SSL, so you'll want to - use the HTTPS URL provided by ngrok. - -Run ngrok and copy the **HTTPS** URL - -.. code:: - - ngrok http 3000 - -.. code:: - - ngrok by @inconshreveable (Ctrl+C to quit) - - Session status online - Version 2.1.18 - Region United States (us) - Web Interface http://127.0.0.1:4040 - - Forwarding http://h7465j.ngrok.io -> localhost:9292 - Forwarding https://h7465j.ngrok.io -> localhost:9292 - -**🤖 Run the app:** - -You'll need to have your server and ngrok running to complete your app's Event -Subscription setup - -.. code:: - - python example.py - - -**🤖 Subscribe your app to events** - -Add your **Request URL** (your ngrok URL + ``/slack/events``) and subscribe your app to `message.channels` under bot events. **Save** and toggle **Enable Events** to `on` - -.. image:: https://user-images.githubusercontent.com/1573454/30185162-644d0cb8-93ee-11e7-96af-55fe10d9d5c8.png - -.. image:: https://cloud.githubusercontent.com/assets/32463/24877931/e119181a-1de5-11e7-8b0c-fcbc3419bad7.png - -**🎉 Once your app has been installed and subscribed to Bot Events, you will begin receiving event data from Slack** - -**👋 Interact with your bot:** - -Invite your bot to a public channel, then say hi and your bot will respond - - hi @bot 👋 - -.. image:: https://cloud.githubusercontent.com/assets/32463/23047918/964defec-f467-11e6-87c3-9c7da11fc810.gif - -🤔 Support ------------- - -Need help? Join `Bot Developer Hangout`_ and talk to us in `#slack-api`_. - -You can also `create an Issue`_ right here on GitHub. - -.. _Bot Developer Hangout: http://dev4slack.xoxco.com/ -.. _#slack-api: https://dev4slack.slack.com/messages/slack-api/ -.. _create an Issue: https://github.com/slackapi/node-slack-events-api/issues/new diff --git a/example/python2/example.py b/example/python2/example.py deleted file mode 100644 index 59bf966..0000000 --- a/example/python2/example.py +++ /dev/null @@ -1,40 +0,0 @@ -from slackeventsapi import SlackEventAdapter -from slackclient import SlackClient -import os - -# Our app's Slack Event Adapter for receiving actions via the Events API -slack_signing_secret = os.environ["SLACK_SIGNING_SECRET"] -slack_events_adapter = SlackEventAdapter(slack_signing_secret, "/slack/events") - -# Create a SlackClient for your bot to use for Web API requests -slack_bot_token = os.environ["SLACK_BOT_TOKEN"] -slack_client = SlackClient(slack_bot_token) - -# Example responder to greetings -@slack_events_adapter.on("message") -def handle_message(event_data): - message = event_data["event"] - # If the incoming message contains "hi", then respond with a "Hello" message - if message.get("subtype") is None and "hi" in message.get('text'): - channel = message["channel"] - message = "Hello <@%s>! :tada:" % message["user"] - slack_client.api_call("chat.postMessage", channel=channel, text=message) - - -# Example reaction emoji echo -@slack_events_adapter.on("reaction_added") -def reaction_added(event_data): - event = event_data["event"] - emoji = event["reaction"] - channel = event["item"]["channel"] - text = ":%s:" % emoji - slack_client.api_call("chat.postMessage", channel=channel, text=text) - -# Error events -@slack_events_adapter.on("error") -def error_handler(err): - print("ERROR: " + str(err)) - -# Once we have our event listeners configured, we can start the -# Flask server with the default `/events` endpoint on port 3000 -slack_events_adapter.start(port=3000) diff --git a/example/python2/requirements.txt b/example/python2/requirements.txt deleted file mode 100644 index 0836610..0000000 --- a/example/python2/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -slackclient<2 -slackeventsapi>=0.1 diff --git a/example/requirements.txt b/example/requirements.txt index 842a8cf..b08ecbe 100644 --- a/example/requirements.txt +++ b/example/requirements.txt @@ -1,2 +1,2 @@ -slackclient>=2.7.1 -slackeventsapi>=2.1.0 +slack-sdk>=3,<4 +slackeventsapi>=3,<4 diff --git a/example/working_with_proxy/example.py b/example/working_with_proxy/example.py index 2f70ff7..e382605 100644 --- a/example/working_with_proxy/example.py +++ b/example/working_with_proxy/example.py @@ -1,15 +1,5 @@ -# ------------------ -# Only for running this script here -import logging -import sys -from os.path import dirname - -sys.path.insert(1, f"{dirname(__file__)}/../..") -logging.basicConfig(level=logging.DEBUG) -# ------------------ - from slackeventsapi import SlackEventAdapter -from slack import WebClient +from slack_sdk.web import WebClient import os slack_signing_secret = os.environ["SLACK_SIGNING_SECRET"] @@ -21,6 +11,17 @@ slack_bot_token = os.environ["SLACK_BOT_TOKEN"] slack_client = WebClient(token=slack_bot_token, proxy=proxy_info) +# Example responder to bot mentions +@slack_events_adapter.on("app_mention") +def handle_mentions(event_data): + event = event_data["event"] + slack_client.chat_postMessage( + channel=event["channel"], + text=f"You said:\n>{event['text']}", + ) + + +# Example responder to greetings @slack_events_adapter.on("message") def handle_message(event_data): message = event_data["event"] diff --git a/example/working_with_proxy/requirements.txt b/example/working_with_proxy/requirements.txt index 170f1b3..65eaf7b 100644 --- a/example/working_with_proxy/requirements.txt +++ b/example/working_with_proxy/requirements.txt @@ -1,4 +1,4 @@ -slackclient>=2.7.1 -slackeventsapi>=2.1.0 -flask>=1 +slack-sdk>=3,<4 +slackeventsapi>=3,<4 +flask>=2,<3 proxy.py>=2.1.2 \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index ffa326b..c7bd54e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,8 +1,7 @@ -coveralls<2 -pytest<6 # python 2.7 requires pytest 4 -pytest-flask<2 -pytest-mock<2 -pytest-cov<3 -pytest-pythonpath<0.8 -testfixtures<7 -werkzeug<2 \ No newline at end of file +flask +werkzeug +pytest +pytest-mock +pytest-cov +pytest-flask +testfixtures \ No newline at end of file diff --git a/scripts/deploy_to_prod_pypi_org.sh b/scripts/deploy_to_prod_pypi_org.sh new file mode 100755 index 0000000..206e705 --- /dev/null +++ b/scripts/deploy_to_prod_pypi_org.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +script_dir=`dirname $0` +cd ${script_dir}/.. +rm -rf ./slackeventsapi.egg-info + +pip install -U pip && \ + pip install twine wheel setuptools && \ + rm -rf dist/ build/ slackeventsapi.egg-info/ && \ + python setup.py sdist bdist_wheel && \ + twine check dist/* && \ + twine upload dist/* diff --git a/run_clean_test.sh b/scripts/run_clean_test.sh similarity index 53% rename from run_clean_test.sh rename to scripts/run_clean_test.sh index f181115..07eb46f 100755 --- a/run_clean_test.sh +++ b/scripts/run_clean_test.sh @@ -1,6 +1,6 @@ #!/bin/bash pip install -U pip && \ -pip freeze | xargs pip uninstall -y && \ -python setup.py install && \ +pip freeze | grep -v '-e' | xargs pip uninstall -y && \ +pip install -e . && \ pip install -r requirements-dev.txt && \ pytest tests diff --git a/setup.py b/setup.py index dfc5071..d4f21b7 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,15 @@ -from setuptools import setup -import codecs import os import re +from setuptools import setup + here = os.path.abspath(os.path.dirname(__file__)) # Read the version number from a source file. # Why read it, and not import? # see https://groups.google.com/d/topic/pypa-dev/0PkjVpcxTzQ/discussion def find_version(*file_paths): - # Open in Latin-1 so that we avoid encoding errors. - # Use codecs.open for Python 2 compatibility - with codecs.open(os.path.join(here, *file_paths), 'r', 'latin1') as f: + with open(os.path.join(here, *file_paths), 'r') as f: version_file = f.read() # The version line must have the form @@ -29,18 +27,16 @@ def find_version(*file_paths): version=find_version('slackeventsapi', 'version.py'), description='Python Slack Events API adapter for Flask', url='http://github.com/slackapi/python-slack-events-api', - author='Slack Technologies, Inc.', + author='Slack Technologies, LLC', author_email='opensource@slack.com', license='MIT', packages=['slackeventsapi'], + python_requires=">=3.7", long_description_content_type='text/x-rst', long_description=long_description, install_requires=[ - 'flask>=1,<2', - 'pyee>=7,<8', - 'itsdangerous<2', # for Python 2.7 - 'Jinja2<3', # for Python 2.7 - 'MarkupSafe<2', # for Python 2.7 + 'flask>=2,<4', + 'pyee>=8,<12', ], classifiers=[ 'Development Status :: 5 - Production/Stable', @@ -50,10 +46,12 @@ def find_version(*file_paths): 'Topic :: Office/Business', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', ], zip_safe=False) diff --git a/slackeventsapi/server.py b/slackeventsapi/server.py index 74afca5..a83f0bb 100644 --- a/slackeventsapi/server.py +++ b/slackeventsapi/server.py @@ -108,7 +108,8 @@ def event(): # Echo the URL verification challenge code back to Slack if "challenge" in event_data: return make_response( - event_data.get("challenge"), 200, {"content_type": "application/json"} + {"challenge": event_data.get("challenge")}, 200, + {"content_type": "application/json"} ) # Parse the Event payload and emit the event to the event listener diff --git a/slackeventsapi/version.py b/slackeventsapi/version.py index 981aab9..5564808 100644 --- a/slackeventsapi/version.py +++ b/slackeventsapi/version.py @@ -1,2 +1,2 @@ # see: http://legacy.python.org/dev/peps/pep-0440/#public-version-identifiers -__version__ = '2.2.1' +__version__ = '3.0.3' diff --git a/tests/test_server.py b/tests/test_server.py index a66a560..7647ff8 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -53,7 +53,7 @@ def test_url_challenge(client): } ) assert res.status_code == 200 - assert bytes.decode(res.data) == "valid_challenge_token" + assert res.json.get("challenge") == "valid_challenge_token" def test_no_request_timestamp_header(client): diff --git a/tox.ini b/tox.ini index 9f13359..ea4f27a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ ; for quality analysis, use `tox -e flake8` or just `flake8 slackeventsapi` ; to build the docs, use `tox -e docs` envlist= - py{276,27,34,35,36}, + py{35,36,37,38,39}, flake8, docs