Slack bot
NOTE: This bot is single-threaded since I am too lazy to update the project with ThreadPoolExecutor
for concurrent IO.
This bot is ready to be deployed to Heroku (Procfile and requirements.txt are created and filled).
If you want to use celery and write your own tasks for it add to Procfile:
worker: celery worker --app=bot.celery.app
Available plugins right now:
NOTE: You can remove plugins from plugins/ directory if you don’t want to use them.
All you need to do is to specify these ENV_VARIABLES:
If you want to run it locally - just clone repo, specify ENV variables and make:
python bot/core.py
NOTE Use celery with AMQP Broker for it
For example you want to post to your channel random file
from you storage using files
plugin periodically:
# file: bot/tasks.py
@app.task
def post_random_webm():
files_cls = import_string(files_cls_str)
files_plugins = [
p for p in slack_backend.plugins
if isinstance(p, files_cls)
]
file_plugin = files_plugins[0]
file_plugin.randomize('games')
And then you just add it to celerybeat cron jobs:
# file bot/celery.py
@app.on_after_configure.connect
def add_periodic(**kwargs):
from bot.tasks import post_random_webm
app.add_periodic_task(
crontab(minute=0,
hour='7,8,9,10,11,12,13,14,15,16,17,18'),
post_random_webm.s(),
name='Post random WEBM'
)