<commit_before>Slack Events API adapter as a Django app
========================================

**django-slack-events-api** is a minimal Django app for making your Slack bot.

It includes a Django porting of the official Slack Events API adapter:
`python-slack-events-api`_.  The original adapter is based on the `Flask
framework`_; so here's a modular Django app version instead ;-)

.. _python-slack-events-api: https://github.com/slackapi/python-slack-events-api
.. _Flask framework: https://github.com/pallets/flask

This is intended to minimal (devoid of extra model, template, and
module-dependency stuffs) focusing only on `Slack Events`_ handling.  However,
all the features and examples useful for Slack bot creation (such as utilizing
the `python-slackclient`_) found in the original Flask version are retained and
functional.  After working through `the demo section`_, you'll find it easy to
integrate this app into your Django projects as well.

.. _Slack Events: https://api.slack.com/events-api
.. _python-slackclient: https://github.com/slackapi/python-slackclient

**Bonus:** Additionally, django-slack-events-api supports three kinds of Slack client
library integration:

- the official `Slack Developer Kit for Python (aka. python-slackclient)`_ [default],
- the popular `slacker client`_, and
- `a minimal client`_ based on `urllib2`_ (compatible with Google App Engine thanks to no socket module dependency).

.. _Slack Developer Kit for Python (aka. python-slackclient): https://github.com/slackapi/python-slackclient
.. _slacker client: https://github.com/os/slacker
.. _a minimal client: slack/client_urllib2.py
.. _urllib2: https://docs.python.org/2/howto/urllib2.html

**Credits:** Sections marked by 🤖 is a derived work of `python-slack-events-api/example/README.rst`_.

Installation
-----------------

**Tested environment:**

- Python 2.7
- Django 1.8.9

**Install the app and its dependencies:**

.. code::

   $ git clone https://github.com/mm-jay/django-slack-events-api.git
   $ cd django-slack-events-api
   $ pip install -r requirements.txt

.. _the demo section:

Demo: creating a minimal Django project for a Slack bot
-----------------------------------------------------------

In this section, we present a quick demo on how to get a working Django-based
Slack bot on your local computer.  We create a new Django app from scratch and
embed the django-slack app in it.  After configurations, we start the
Django local server on port 3000.  ngrok_ is used to make sure that the local
bot instance is properly communicating with the Slack server on the Internet.

.. _ngrok: https://ngrok.com

**(1) A new django project with a django slack app embedded**

.. code::

   $ django-admin startproject bot  # create a new django project called "bot"
   $ cp -r slack bot/               # copy (embed) the bare django-slack app under the bot project
   $ cd bot                         # move into the root of the bot project

Now the current directory structure should look as follows:
   
.. code::

   $ find .    
   .                               # Root of the new "bot" project
   ./bot
   ./bot/__init__.py
   ./bot/settings.py               # to be modified
   ./bot/urls.py                   # to be modified<commit_msg>removed a broken link when rendered in github<commit_after>Slack Events API adapter as a Django app
========================================

**django-slack-events-api** is a minimal Django app for making your Slack bot.

It includes a Django porting of the official Slack Events API adapter:
`python-slack-events-api`_.  The original adapter is based on the `Flask
framework`_; so here's a modular Django app version instead ;-)

.. _python-slack-events-api: https://github.com/slackapi/python-slack-events-api
.. _Flask framework: https://github.com/pallets/flask

This is intended to minimal (devoid of extra model, template, and
module-dependency stuffs) focusing only on `Slack Events`_ handling.  However,
all the features and examples useful for Slack bot creation (such as utilizing
the `python-slackclient`_) found in the original Flask version are retained and
functional.  After working through the demo section, you'll find it easy to
integrate this app into your Django projects as well.

.. _Slack Events: https://api.slack.com/events-api
.. _python-slackclient: https://github.com/slackapi/python-slackclient

**Bonus:** Additionally, django-slack-events-api supports three kinds of Slack client
library integration:

- the official `Slack Developer Kit for Python (aka. python-slackclient)`_ [default],
- the popular `slacker client`_, and
- `a minimal client`_ based on `urllib2`_ (compatible with Google App Engine thanks to no socket module dependency).

.. _Slack Developer Kit for Python (aka. python-slackclient): https://github.com/slackapi/python-slackclient
.. _slacker client: https://github.com/os/slacker
.. _a minimal client: slack/client_urllib2.py
.. _urllib2: https://docs.python.org/2/howto/urllib2.html

**Credits:** Sections marked by 🤖 is a derived work of `python-slack-events-api/example/README.rst`_.

Installation
-----------------

**Tested environment:**

- Python 2.7
- Django 1.8.9

**Install the app and its dependencies:**

.. code::

   $ git clone https://github.com/mm-jay/django-slack-events-api.git
   $ cd django-slack-events-api
   $ pip install -r requirements.txt

Demo: creating a minimal Django project for a Slack bot
-----------------------------------------------------------

In this section, we present a quick demo on how to get a working Django-based
Slack bot on your local computer.  We create a new Django app from scratch and
embed the django-slack app in it.  After configurations, we start the
Django local server on port 3000.  ngrok_ is used to make sure that the local
bot instance is properly communicating with the Slack server on the Internet.

.. _ngrok: https://ngrok.com

**(1) A new django project with a django slack app embedded**

.. code::

   $ django-admin startproject bot  # create a new django project called "bot"
   $ cp -r slack bot/               # copy (embed) the bare django-slack app under the bot project
   $ cd bot                         # move into the root of the bot project

Now the current directory structure should look as follows:
   
.. code::

   $ find .    
   .                               # Root of the new "bot" project
   ./bot
   ./bot/__init__.py
   ./bot/settings.py               # to be modified
   ./bot/urls.py                   # to be modified
{'fraction_non_alphanumeric': 0.12194002447980416, 'fraction_numerical': 0.004589963280293758, 'mean_word_length': 2.9932803909590713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4382756', 'n_tokens_mistral': 1879, 'n_tokens_neox': 1806, 'n_words': 751}