Skip to main content

This is a django wrapper to handle slack events and slash commands.

Project description

DJANGO SLACK EVENT WRAPPER

This is a django wrapper to handle slack events and slash commands. It also verifies incoming events using x-slack-signature and x-slack-timestamp. It receives slack events, slash commands and delivers gracefully with the events.

CONFIGURATION AND SETUP

>settings.py
INSTALLED_APPS = [
    'django_slack_event_wrapper',
    ...
]

CONFIGURATIONS
=============

VERIFICATION_TOKEN = XXXXXXXXXXXXXXXXXXXXX
SIGNING_SECRET = XXXXXXXXXXXXXXXXXXXXX
APP_ID = XXXXXXXXXXXXXXXXXXXXX
OAUTH_TOKEN = XXXXXXXXXXXXXXXXXXXXX
BOT_ID = XXXXXXXXXXXXXXXXXXXXX

>urls.py
    open your projects urls.py file and add the following
    urlpatterns = [
        path('slack-app/', include('django_slack_event_wrapper.urls')),
        ....
    ]
    Note: you can change the name from slack-app to whatever you like.

When registering your webhook urls to slack, you use the following:

    1. For Events: http[s]://yourdomain.name/slack-app/events [If you changed the root url name, you but that instead of slack-app]

    2. For Slash Commands: http[s]://yourdomain.name/slack-app/slash-commands [If you changed the root url name, you but that instead of slack-app]

EXAMPLE

    NOTE: Create A slack.py file
    from django_slack_event_wrapper.dispatcher import slack_event_emitter, slash_command_emitter
    from rest_framework.response import Response

EVENT

    @slack_event_emitter("message")
    def on_message(event, **kwargs):
        print(event)
        # have fun


SLASH COMMAND


    @slash_command_emitter('/message-count')
    def message_count(user_id, channel_id, slash_event_data, **kwargs):
        print(user_id, channel_id)
        # have fun

Change Log

==========

0.1.12(11-10-2021)

  • First Release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_slack_event_wrapper-0.1.12.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file django_slack_event_wrapper-0.1.12.tar.gz.

File metadata

  • Download URL: django_slack_event_wrapper-0.1.12.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

File hashes

Hashes for django_slack_event_wrapper-0.1.12.tar.gz
Algorithm Hash digest
SHA256 c298f80526e5c2f49a1e9446adaa2034f9c0c76cd1f8645dac6418c8094d4f99
MD5 a043e9190802dd54200db4cf2522fa7b
BLAKE2b-256 a98de466db25b4ce545dd1f942503846545421324057733e5ff8e670279ce038

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page