slack-bot
Application for easy make slack bot
Content:
Getting Started:
Installing:
pip install slack-bot
Usage:
Code for base slack bot:
# 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:
Dockerfile example:
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.routedecorator
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
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
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 file for details
Dependencies:
base
pip==19.0.3
setuptools==41.0.0
application dependencies
slackclient==1.3.1
parse==1.12.0
slackclient dependencies
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
Metadata
Release files for slack-bot 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| slack_bot-0.0.7.tar.gz | 6.0 kB | Without provenance | Details for slack_bot-0.0.7.tar.gz |
Release files / slack_bot-0.0.7.tar.gz
| Download URL | slack_bot-0.0.7.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1298fe6c7a9d929128aa004a9cfb70343d38e6bad3a688b80a1c8d78b7fcc2aa
|
|
BLAKE2b-256 checksum How to use checksums |
d8c786dc3092691638f7f1a1a0fb0e98deae53fad2b6567d50173045ccdd7243
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7
|
Security for slack-bot 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.