{ "info": { "author": "mongkok", "author_email": "domake.io@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Flask", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask Slack Events\n==================\n\n|Pypi| |Build Status| |Codecov| |Code Climate|\n\n\n`Slack event subscriptions `_ for `Flask `_\n\n\nInstallation\n------------\n\nInstall last stable version from Pypi::\n\n pip install flask-slack-events\n\n\nCreate a Slack bot user\n-----------------------\n\nSee the `Slack's documentation `_ for further guidance on creating your bot (**step 1**).\n\nWithin the *Basic Information* about your application, copy the **Signing Secret** necessary to `verify requests from Slack `_.\n\n.. image:: https://user-images.githubusercontent.com/5514990/53696736-cfde0e00-3dfc-11e9-9aeb-23d184f8c600.png\n :alt: Signing Secret\n\n\nConfigure your Application\n--------------------------\n\nYou should create a ``SlackManager`` object within your application:\n\n.. code-block:: python\n\n slack_manager = SlackManager()\n\n`Configure your application object `_ updating the ``SLACK_SIGNING_SECRET`` key with the value obtained in the previous **step 1**:\n\n.. code-block:: python\n\n app.config['SLACK_SIGNING_SECRET'] = ''\n\nOnce the actual application object has been created, you can configure it for *SlackManager* object with::\n\n slack_manager.init_app(app)\n\n\nConfigure your Slack Bot\n------------------------\n\nContinue with the `Slacks's documentation `_ to setting up the Events API (**step 2**) and enter the URL to receive the subscriptions joining your host and the relative path ``/slack/events``:\n\n.. image:: https://user-images.githubusercontent.com/5514990/53696747-e5533800-3dfc-11e9-8cef-4fd13d06e6ef.png\n :alt: Enable Event\n\nFinally, install your bot to a workspace (**step 3**).\n\n\nHow it Works\n------------\n\nNow in order to subscribe to `Slack Events `_, use the ``SlackManager.on`` decorator:\n\n.. code-block:: python\n\n # Reply to only the message events that mention your bot\n\n @slack_manager.on('app_mention')\n def reply_to_app_mention(sender, data, **extra):\n event = data['event']\n\n slack_client.api_call(\n 'chat.postMessage',\n channel=event['channel'],\n text=f\":robot_face: Hello <@{event['user']}>!\")\n\n\nContext Processors\n------------------\n\nTo inject new variables automatically into the context of a handler, context processors exist in *Flask-Slack-Events*.\n\nA context processor is a function that returns a dictionary:\n\n.. code-block:: python\n\n @slack_manager.context_processor\n def context_processor(data):\n return dict(my_bot_id='UAZ02BCBH')\n\nThe injected variables will be sent as an ``extra`` argument for each event handler ``f(sender, data, **extra)``.\n\n\nDispatch Events Asynchronously\n------------------------------\n\nSome event handlers can delay the execution of another, to avoid this you can configure the event dispatcher and call handlers asynchronously:\n\n.. code-block:: python\n\n @slack_manager.dispatch_event_handler\n def async_event_dispatcher(sender, data, handlers, **extra):\n for handler in handlers:\n task(handler)(data, **extra)\n\n\nSubscribe to Signals\n--------------------\n\nThe following signals are sended internally by *Flask-Slack-Events*:\n\nsignals.request_unauthorized\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Sent when the request received is unauthorized\n\n Receiver: ``f(sender, **extra)``\n\nsignals.expired_event\n~~~~~~~~~~~~~~~~~~~~~\n\n Sent when the event has expired according to the value of ``SLACK_EVENT_EXPIRATION_DELTA`` and the HTTP header ``X-Slack-Request-Timestamp`` received\n\n Receiver: ``f(sender, **extra)``\n\nsignals.invalid_signature\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Sent when the signature included within the HTTP header ``X-Slack-Signature`` is invalid\n\n Receiver: ``f(sender, **extra)``\n\n\nsignals.event_received\n~~~~~~~~~~~~~~~~~~~~~~\n\n Sent when an event has been received\n\n Receiver: ``f(sender, data, **extra)``\n\n\nSlackManager Handlers\n---------------------\n\nThe following handlers are used internally by *Flask-Slack-Events*:\n\nSlackManager.unauthorized_handler\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Called to handle an unauthorized request\n\n Handler: ``f()``\n\n Default: ``SlackManager.unauthorized()``\n\nSlackManager.expired_event_handler\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Called to handle an expired event\n\n Handler: ``f()``\n\n Default: ``SlackManager.expired_event()``\n\nSlackManager.invalid_signature_handler\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Called to handle a request with an invalid signature\n\n Handler: ``f()``\n\n Default: ``SlackManager.invalid_signature()``\n\n\nSlackManager.dispatch_event_handler\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Called to dispatch the event to all handlers connected with ``SlackManager.on(event_type)`` decorator\n\n Handler: ``f(sender, data, handlers, **extra)``\n\n Default: ``SlackManager.dispatch_event(data)``\n\n\nConfiguration\n-------------\n\nThe following configuration values are used internally by *Flask-Slack-Events*:\n\nSLACK_SIGNING_SECRET\n~~~~~~~~~~~~~~~~~~~~\n\n Signing Secret to verify whether requests from *Slack* are authentic\n\n Default: ``''``\n\nSLACK_EVENTS_URL\n~~~~~~~~~~~~~~~~\n\n URL rule that is used to register the *Subscription View*\n\n Default: ``/slack/events``\n\nSLACK_EVENT_EXPIRATION_DELTA\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Timedelta added to ``time.time()`` to set the expiration time of each event\n If the value is ``None`` then the event never expires\n\n Default: ``timedelta(seconds=60 * 5)`` (5 minutes)\n\n\nMarvin the Paranoid Android\n---------------------------\n\n`Marvin `_ is a **Slack Bot layout** for *Flask* to develop `Slack Event `_ handlers and deploy on *AWS Lambda* + *API Gateway*\n\n\n.. |Pypi| image:: https://img.shields.io/pypi/v/flask-slack-events.svg\n :target: https://pypi.python.org/pypi/flask-slack-events\n :alt: Pypi\n\n.. |Build Status| image:: https://travis-ci.org/longstem/flask-slack-events.svg?branch=master\n :target: https://travis-ci.org/longstem/flask-slack-events\n :alt: Build Status\n\n.. |Codecov| image:: https://img.shields.io/codecov/c/github/longstem/flask-slack-events.svg\n :target: https://codecov.io/gh/longstem/flask-slack-events\n :alt: Codecov\n\n.. |Code Climate| image:: https://api.codeclimate.com/v1/badges/c79a185d546f7e34fdd6/maintainability\n :target: https://codeclimate.com/github/longstem/flask-slack-events\n :alt: Codeclimate\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/longstem/flask-slack-events", "keywords": "flask", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "Flask-Slack-Events", "package_url": "https://pypi.org/project/Flask-Slack-Events/", "platform": "", "project_url": "https://pypi.org/project/Flask-Slack-Events/", "project_urls": { "Homepage": "https://github.com/longstem/flask-slack-events" }, "release_url": "https://pypi.org/project/Flask-Slack-Events/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Slack event subscriptions for Flask", "version": "0.0.2" }, "last_serial": 4895876, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "1e1d04c97c0240eff71b035a783130b8", "sha256": "d5a73a939190ea1a92c206740225e071769f3aac0b554628a53fea62d058a7bc" }, "downloads": -1, "filename": "Flask_Slack_Events-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1e1d04c97c0240eff71b035a783130b8", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 7147, "upload_time": "2019-03-03T20:41:51", "url": "https://files.pythonhosted.org/packages/18/7f/0113551c41d10b4ab7ff96eff81ca8442fe82ed6bdb378361b8991ff123c/Flask_Slack_Events-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b1aee41b35878fae073f5dcbf1e4a55e", "sha256": "5651118eab6f715a996accfcea703c82aef43fab4f8efce9c0dec427c573f54c" }, "downloads": -1, "filename": "Flask-Slack-Events-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b1aee41b35878fae073f5dcbf1e4a55e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6521, "upload_time": "2019-03-03T20:41:35", "url": "https://files.pythonhosted.org/packages/f9/8d/4898f4b300e9c2933e0b4f79a8ab0d7ce21f81157a91f64c0ee18caad82a/Flask-Slack-Events-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "e42155aef45a402635aebd559f404bcb", "sha256": "327e89b951ca01dc0f182c6227f1262884a023c2de097274e4efc607a374894f" }, "downloads": -1, "filename": "Flask_Slack_Events-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e42155aef45a402635aebd559f404bcb", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 7516, "upload_time": "2019-03-04T19:20:52", "url": "https://files.pythonhosted.org/packages/76/53/8a4f369ac9a93c02907eae12c7f8ea946d6aa524bc4bc0f53ce2375b494a/Flask_Slack_Events-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0a93fbc0661b409d8d3982624c04a8c", "sha256": "b696c151c875bc349861e6906fb90f3ef7d920a428e667e7e0c6e82735e045c7" }, "downloads": -1, "filename": "Flask-Slack-Events-0.0.2.tar.gz", "has_sig": false, "md5_digest": "f0a93fbc0661b409d8d3982624c04a8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6979, "upload_time": "2019-03-04T19:20:47", "url": "https://files.pythonhosted.org/packages/59/48/4e9d146e14fb49eb85c5746d3e1389a64bee9ddc62a35c125d39a17175ee/Flask-Slack-Events-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e42155aef45a402635aebd559f404bcb", "sha256": "327e89b951ca01dc0f182c6227f1262884a023c2de097274e4efc607a374894f" }, "downloads": -1, "filename": "Flask_Slack_Events-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e42155aef45a402635aebd559f404bcb", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 7516, "upload_time": "2019-03-04T19:20:52", "url": "https://files.pythonhosted.org/packages/76/53/8a4f369ac9a93c02907eae12c7f8ea946d6aa524bc4bc0f53ce2375b494a/Flask_Slack_Events-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0a93fbc0661b409d8d3982624c04a8c", "sha256": "b696c151c875bc349861e6906fb90f3ef7d920a428e667e7e0c6e82735e045c7" }, "downloads": -1, "filename": "Flask-Slack-Events-0.0.2.tar.gz", "has_sig": false, "md5_digest": "f0a93fbc0661b409d8d3982624c04a8c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6979, "upload_time": "2019-03-04T19:20:47", "url": "https://files.pythonhosted.org/packages/59/48/4e9d146e14fb49eb85c5746d3e1389a64bee9ddc62a35c125d39a17175ee/Flask-Slack-Events-0.0.2.tar.gz" } ] }