Our lovely opinionated Slack bot. Find it in BcnEng Slack workspace as @candebot.
- Commands emulating a command line tool. Via Slack slash (
/) or mentioning the bot. See /cmd. For example:coc- Shows the Code of Conduct.netiquette- Shows the Netiquette.staff- Shows the list of staff members.echo- Sending messages as the bot user. Only available to admins.candebirthday- Days until @sdecandelario birthday! Something people cares.
- Filter stopwords in messages. Suggest more inclusive alternatives to the user. See /inclusion.
- Submission and validation of job posts. Posted in the
#hiring-job-boardchannel via a form. - Rate limiting for messages. Limit how many non-thread messages users can post in configured channels. Staff members are exempt.
- Tracking parameter detection. Detects privacy-invasive tracking parameters in shared URLs and privately warns users with cleaned alternatives.
- Message actions. For example:
- Deleting a message and the whole thread. Only available to admins.
- Report messages to the admins.
Candebot can be configured via Toml file + environment variables. The need for setting up environment variables when using the Toml file is due to the fact that some of the configurations is sensitive and should not be stored in a file.
All environment variables are prefixed with BOT_. For example, BOT_BOT_USER_TOKEN. If you want to change the prefix, you can set -env-prefix <prefix> flag when running the bot.
The following environment variables are needed in order to run the bot:
BOT_BOT_USER_TOKEN- Slack bot user token. Used to authenticate the bot user.BOT_BOT_ADMIN_TOKEN- Slack user token with admin rights. Used to authenticate the bot user when performing admin actions.BOT_BOT_SERVER_SIGNING_SECRET- Slack app signing secret. Used to verify the authenticity of the requests.
There are more environment variables that can be set. Please, check /bot/config.go.
By default, ./.bot.toml is used as the configuration file. If you want to change the path, you can set -config <filepath> flag when running the bot.
Please, use the following file as a reference.
Configure rate limits for specific channels using the rate_limits section. You can define multiple channels, each with their own limits:
[[rate_limits]]
channel_name = "random"
rate_limit_seconds = 86400
max_messages = 1
[[rate_limits]]
channel_name = "candebot-testing"
rate_limit_seconds = 60
max_messages = 2
apply_to_staff = truechannel_name: Name of the channel to apply rate limitingrate_limit_seconds: Time window in secondsmax_messages: Maximum number of non-thread messages allowed in the time windowapply_to_staff: (optional, default: false) If true, staff members are also rate limited in this channel
By default, staff members are exempt from rate limits. Set apply_to_staff = true to apply limits to staff as well. When a user exceeds the limit, their message is deleted and they receive a DM with the message link and time until they can post again.
Configure tracking parameter detection using the tracking_detection section. By default (no config), tracking detection runs in all channels. To limit to specific channels:
[[tracking_detection]]
channel_name = "general"
[[tracking_detection]]
channel_name = "random"channel_name: Name of the channel to enable tracking detection
When a message contains URLs with tracking parameters (like Instagram's igsh, Facebook's fbclid, etc.), the bot sends an ephemeral (private) message to the user warning them about the tracking parameter and providing a cleaned URL without tracking.
go get -u github.com/bcneng/candebot
BOT_BOT_USER_TOKEN=<slack-bot-user-token> \
BOT_BOT_ADMIN_TOKEN=<slack-user-with-admin-rights-token> \
BOT_BOT_SERVER_SIGNING_SECRET=<slack-app-signing-secret> \
candebot
You can get your bot user token by creating a Slack app via https://api.slack.com/apps.
There is no preference for deployment. You can deploy it in any way you want. For example, using Docker. The files required will always be:
- Compiled binary of the bot.
.bot.tomlfile with the configuration.
