Thug memes from Slack image uploads.
Messages that are posted in threads of uploaded images and start with thug or Thug are considered as commands to create and upload thug memes based on the original image and given command. Any member of a public channel (which thug bot is also part of) can thug anyone's uploads.
- thug: creates a thug meme without any texts
- thug some message: creates a thug meme with some message as text in the upper part of the image
- thug "some message" "some other message": creates a thug meme with some message as text in the upper part and some other message in the lower part of the image
- thug "some message" "some other message" -o configoption foo: same as previous but also overrides default value of configoption by value foo while creating thug meme.
Multiple config options can be overridden by mentioning
-o
flag multiple times. See full list of available thug meme configuration options here.slack-thug
uses dlib detector ofthug-memes
so opencv* config options in detect section are not relevant.
If there's an issue while creating the thug meme, the bot will reply nicely in the Slack thread of the given thug command with some additional details about what went wrong.
- Python all the way
- Minimal Flask app
- Redis Queue rq
- SQLite db
- Docker Compose
- slackclient
- Poetry
- Access the web UI of your workspace, e.g. click your workspace name in Slack desktop application and select Customize Slack
- Configure apps -> Build (top right corner) -> Your Apps -> Create an App
- Give you app a dope name and select workspace
- Bot Users -> Add a bot user -> configure display name and default name -> Add Bot User -> Save changes
- Your Apps -> your app name -> Install your app to your workspace -> Install App to Workspace -> Authorize
- OAuth & Permissions -> Bot User OAuth Access Token
- Save the token as env variable, e.g.
export SLACK_TOKEN=<the token>
NOTE: the slack-thug
application should be running before the next step.
- Event Subscriptions -> Enable Events
- Fill Request URL: <your_url>/event (see Endpoint for Slack App below), you should see green at this point if everything is ok
- The bot requires access to messages: Add Bot User Event -> add
message.channels
-> Save Changes
- Invite the bot to public channel(s) in which you want to thug image uploads.
NOTE: make sure SLACK_TOKEN
env variable is configured at this point.
- Install Docker Engine and Docker Compose if you don't have those.
- Run docker-compose up. Hold your horses though, installing
dlib
inside a docker image takes a while.
docker-compose up
slack-thug
relies heavily onthug-memes
which in turn usesdlib
under the hood. Here's one guide for installingdlib
on different platforms.slack-thug
usespoetry
for dependency management, install deps by:
poetry install
slack-thug
usesredis
for the communication between the web app and the worker process. Install redis and run redis server.- Run the worker
poetry run python -m slack_thug.worker
- Run the web app (on a separate console)
poetry run python -m slack_thug.app
Regardless which installation/running option you used for slack-thug
, the endpoint for Slack App will be accessible in http://localhost:5000/event if default configuration is used. To access this endpoint from outside, you can use e.g. ngrok.
After running ngrok http 5000
, the endpoint (accessible from outside) will be something like https://asfsdfdsg.ngrok.io/event. You can use this while configuring the event subscription for the Slack App.
Better option compared to running stuff locally is obviously to deploy it on your (employer's) favorite hosting provider, which is not covered here.
poetry install
poetry run pytest
- Install it and it'll be ran automatically with every commit
pre-commit install
- Running manually
pre-commit run -a