Metadata-Version: 2.1
Name: slack-bot
Version: 0.0.2
Summary: Simple application for make slack bot
Home-page: https://github.com/DKorytkin/slack-bot
Author: Denis Korytkin
Author-email: dkorytkin@gmail.com
License: MIT license
Keywords: bot,slack,app,slack_bot,app,application
Platform: linux
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Requires-Dist: pip (==19.0.3)
Requires-Dist: setuptools (==41.0.0)
Requires-Dist: certifi (==2019.3.9)
Requires-Dist: chardet (==3.0.4)
Requires-Dist: idna (==2.8)
Requires-Dist: requests (==2.21.0)
Requires-Dist: six (==1.12.0)
Requires-Dist: urllib3 (==1.24.2)
Requires-Dist: websocket-client (==0.47.0)
Requires-Dist: slackclient (==1.3.1)
Requires-Dist: parse (==1.12.0)
Provides-Extra: tests
Requires-Dist: atomicwrites (==1.3.0) ; extra == 'tests'
Requires-Dist: attrs (==19.1.0) ; extra == 'tests'
Requires-Dist: more-itertools (==7.0.0) ; extra == 'tests'
Requires-Dist: pluggy (==0.9.0) ; extra == 'tests'
Requires-Dist: py (==1.8.0) ; extra == 'tests'
Requires-Dist: Pygments (==2.3.1) ; extra == 'tests'
Requires-Dist: bleach (==3.1.0) ; extra == 'tests'
Requires-Dist: docutils (==0.14) ; extra == 'tests'
Requires-Dist: pkginfo (==1.5.0.1) ; extra == 'tests'
Requires-Dist: readme-renderer (==24.0) ; extra == 'tests'
Requires-Dist: requests-toolbelt (==0.9.1) ; extra == 'tests'
Requires-Dist: tqdm (==4.31.1) ; extra == 'tests'
Requires-Dist: webencodings (==0.5.1) ; extra == 'tests'
Requires-Dist: pytest (==4.4.1) ; extra == 'tests'
Requires-Dist: wheel (==0.33.1) ; extra == 'tests'
Requires-Dist: twine (==1.13.0) ; extra == 'tests'


# slack-bot
Application for easy make slack bot

## Content:
  - [Getting started](#getting-started)
    - [How to use](#usage)
    - [Install](#installing)
    - [Dockerfile example](#dockerfile-example)
    - [Examples](#examples)
  - [Authors](#authors)
  - [License](#license)
  - [Dependencies](#dependencies)


## Getting Started:

### Installing:

```bash
pip install slack-bot
```

### Usage:

Code for base slack bot:

```python
# run.py

import os

from slack_bot import Application, Response


app = Application(token=os.getenv('SLACK_TOKEN'))


@app.route('hello')
def main(request):
    return Response(request=request, text=f'Hi! {request.user}')


@app.route('deploy {app:w}')
def deploy_staging(request):
    current_app = request.match_info["app"]
    # body for deploy staging ...
    return Response(request=request, text=f'Start deploy {current_app}')


if __name__ == '__main__':
    app.run()
```
Result:

![chat example](./chat_example.png)

### Dockerfile example:

```dockerfile
FROM python:3.7-alpine

WORKDIR app/

# This env variable by defauult equal 1
ENV RTM_READ_DELAY=1

# Run install your requirements
RUN pip install slack-bot

# Copy application modules to docker container
COPY . /app/

# Run module with intit application
CMD ['python', '/app/run.py']
```

### Examples:
Many examples, how to use `slack-bot` 


- Adding handlers to app with `@app.route` decorator

```python
import os

from slack_bot import Application, Response


TOKEN = os.getenv('SLACK_TOKEN')


app = Application(token=TOKEN)


@app.route('hello', channels=[], users=[])
def main(request):
    return Response(request=request, text=f'Hi! {request.user}')


if __name__ == '__main__':
    app.run()
``` 

- Use routes table, for adding handlers to app

```python
import os

from slack_bot import Application, Response, RoutersTable


table = RoutersTable()


@table.route('hello')
def say_hello(request):
    return Response(request=request, text=f'Hi! {request.user}')


if __name__ == '__main__':
    app = Application(token=os.getenv('SLACK_TOKEN'))
    app.run()

``` 

- Adding all handlers to app

```python
import os

from slack_bot import Application, Response, Route


def say_hello(request):
    return Response(request=request, text=f'Hi! {request.user}')


if __name__ == '__main__':
    app = Application(token=os.getenv('SLACK_TOKEN'))
    app.add_routes([
        Route(route='Hello', handler=say_hello),
    ])
    app.run()
``` 

## Authors:

 - Denis Korytkin

## License:

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details


## Dependencies:

*base*

```bash
pip==19.0.3
setuptools==41.0.0
```

*application dependencies*

```bash
slackclient==1.3.1
parse==1.12.0
```

*slackclient dependencies*

```bash
certifi==2019.3.9
chardet==3.0.4
idna==2.8
requests==2.21.0
six==1.12.0
urllib3==1.24.2
websocket-client==0.47.0
```


