Slack bot that uses message history to create sentences from Markov chains
434
Slack bot that uses message history to create sentences from Markov chains as described here: http://hirelofty.com/blog/how-build-slack-bot-mimics-your-colleague/
Code credit goes to Casey Kinsey.
Only minor modifications were made to containerize the application and change the method of posting to Slack.
The source file is located at /usr/src/parrot-bot.py within the container.
REMEMBER TO PROTECT YOUR SLACK TOKEN! Your personal Slack token has full access to all your message history and can be used to post messages as you through the API!
docker-compose.yml: image: k3vmcd/parrot-bot
environment:
- BOT_TOKEN: this-is-my-bot-token-from-slack
- SEARCH_TOKEN: this-is-my-personal-token-from-slack
- SEARCH_QUERY: from:johnsmith
- BOT_NAME: J Smith Bot
- ICON_URL: https://john's-public-image-url
- PARROT_COMMAND_PHRASE: parrot jsmith
- UPDATE_COMMAND_PHRASE: level up jsmith
volumes:
- /tmp/dockerstorage/JSmithBot/:/mnt
docker run command (note: using an environment variable list file):docker run --name 'JSmithBot' -v /tmp/dockerstorage/JSmithBot/:/mnt --env-file ./env -d k3vmcd/parrot-bot
./env file contents:BOT_TOKEN: this-is-my-bot-token-from-slack
SEARCH_TOKEN: this-is-my-personal-token-from-slack
SEARCH_QUERY: from:johnsmith
BOT_NAME: J Smith Bot
ICON_URL: https://john's-public-image-url
PARROT_COMMAND_PHRASE: parrot jsmith
UPDATE_COMMAND_PHRASE: level up jsmith
docker run command (note: this method puts your slack token into your command line history!):docker run --name 'JSmithBot' \
-v /tmp/dockerstorage/JSmithBot/:/mnt \
-e BOT_TOKEN='this-is-my-bot-token-from-slack' \
-e SEARCH_TOKEN='this-is-my-personal-token-from-slack' \
-e SEARCH_QUERY='from:johnsmith' \
-e BOT_NAME='J Smith Bot' \
-e ICON_URL='https://john's-public-image-url' \
-e PARROT_COMMAND_PHRASE='parrot jsmith' \
-e UPDATE_COMMAND_PHRASE='level up jsmith' \
-d k3vmcd/parrot-bot
BOT_TOKEN Slack token bot will use to post messages (can be your personal OAuth testing token)
SEARCH_TOKEN Slack token bot will use to search for messages
SEARCH_QUERY Slack query to use in retrieving messages (e.g., from:<username> will query all public channels and direct messages the SEARCH_TOKEN user has access to. Alternatively, from:<username> in:<channel> would query only messages from that user in a certain channel).
BOT_NAME The display name of your bot. This will be what appears in conversations.
ICON_URL The publicly accessible icon URL to use for your bot. This will be what appears in conversations.
PARROT_COMMAND_PHRASE The keyword(s) that will trigger a message from your bot. By default it is set to parrot me
UPDATE_COMMAND_PHRASE The keyword(s) that will trigger an update of the message database per the search query. By default it is set to level up parrot
CHANNEL Set this variable to force the bot to always post to a specific channel. By default it is set to post to whatever channel the PARROT_COMMAND_PHRASE is mentioned in.
MESSAGE_PAGE_SIZE The query size limit. By default it is set to 100 messages per page.
DEBUG Setting to enable debug mode. Set to true by default.
<local_storage_directory>:/mntContent type
Image
Digest
Size
27.3 MB
Last updated
almost 10 years ago
docker pull k3vmcd/parrot-bot:v1.1