- Create new custom integration
Bots(e.g https://{team}.slack.com/apps/manage/custom-integrations) - Add bot to channels you want to listen
- Build for your environment or download tarball with binary for your OS and arch
- Prepare config.yaml with duties list
- Run with the required parameters
SDB_SLACK_TOKEN=your-token-here ./slack-duty-bot \
--slack.keyword keyword-1 \
--slack.keyword keyword-2 \
--slack.group.id your-group-id \
--slack.group.name your-group-nameYou also can run in application in docker:
docker run \
--name slack-duty-bot \
--restart on-failure \
-v $(pwd)/config:/etc/slack-duty-bot \
-e SDB_SLACK_TOKEN=your-token-here \
-d \
iqoption/slack-duty-bot:1.1.0 \
--config.path=/etc/slack-duty-bot \
--slack.keyword keyword-1 \
--slack.keyword keyword-2
--slack.group.id your-group-id \
--slack.group.name your-group-name** Golang:1.11 is required **
Build
env GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o slack-duty-bot -vBuild via makefile
make GOOS=linux GOARCH=amd64Build in docker
docker run \
--rm \
-v $(pwd):/project \
-w /project \
-e GOOS=linux \
-e GOARCH=amd64 \
-e GO111MODULE=on \
golang:1.11 go build -o slack-duty-bot -vEnvironment variables are prefixed with SDB_ and MUST be uppercase with _ delimiter
Available variables:
SDB_SLACK_TOKENSDB_SLACK_GROUP_IDSDB_SLACK_GROUP_NAMESDB_SLACK_THREADSSDB_LOGGER_LEVEL
Every environment variable can be overwritten by startup flags
Available flags:
--slack.token- Slack API client token (Required)--slack.keyword- Case insensitive keywords slice to search in message text, can be set multiple times (default: []) (Required)--config.path- Path to config.yaml file (default: . and$HOME/.slack-duty-bot)--slack.group.name- Slack user group name, to mention in channel if duty list is empty--slack.group.id- Slack user group ID, to mention in channel if duty list is empty--slack.threads- Use threads as reply target or push message direct to channel (default:true)--logger.level- Log level (default:info)
You can get IDS from api or just use testing page
There are three ways of configuration for slack-duty-bot
slack:
group:
id: some-group-id
name: some-group-name
In this way slack-duty-bot will always call entire Slack group in case matching keyword in message.
By default duties is an empty slice (or just skipped in config)
duties: []In this case you MUST set slack.group configuration
If you prefer to set different duties for different days, you MUST set duties as slice, containing 7 indexes of slices:
duties:
- [username.one, username.two] # Sunday
- [username.one] # Monday
- [username.two] # Tuesday
- [username.one] # Wednesday
- [username.two] # Thursday
- [username.one] # Friday
- [username.one, username.two] # SaturdayIf you prefer to set custom duties for some days, and call full group for another, just pass duties slice and slack.group configuration together:
slack:
group:
id: some-group-id
name: some-group-name
duties:
- [] # Sunday
- [username.one] # Monday
- [username.two] # Tuesday
- [username.one] # Wednesday
- [username.two] # Thursday
- [username.one] # Friday
- [] # SaturdayAs the result of this configuration, slack-duty-bot will call username.one at Friday and full Slack group some-group-name at Saturday and Sunday
- Flags
- Environment variables
- Config file
The following table lists the configurable parameters of the slack-duty-bot chart and their default values.
| Parameter | Description | Default |
|---|---|---|
image.repository |
SDB image registry | iqoption/slack-duty-bot |
image.tag |
SDB Image tag | {VERSION} |
image.pullPolicy |
SDB image pull policy | IfNotPresent |
configuration.slackToken |
Slack token | nil |
configuration.keywords |
Trigger words | array duty |
helm upgrade --install slack-duty-bot-my-app-name .helm/slack-duty-bot/ --set configuration.slackToken=secret-token,configuration.keywords[0]="duty",configuration.keywords[1]="autobot",dutyUsers.monday=user.one,dutyUsers.tuesday=user.two,dutyUsers.wednesday=user.onekubectl create namespace slack-duty-bot#namespace-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: slack-duty-bot-quota
spec:
hard:
requests.cpu: "2"
requests.memory: 1Gi
limits.cpu: "4"
limits.memory: 2Gikubectl create -f namespace-quota.yaml --namespace=slack-duty-bot#namespace-limit-range.yaml
apiVersion: v1
kind: LimitRange
metadata:
name: slack-duty-bot-limit-range
spec:
limits:
- default:
cpu: "200m"
memory: 128Mi
defaultRequest:
cpu: "100m"
memory: 64Mi
type: Containerkubectl create -f namespace-limit-range.yaml --namespace=slack-duty-bot(docker run \
--rm \
-it \
-v $(pwd):/tmp \
-e SDB_SLACK_TOKEN_BASE64=your-token-hash \
-e SDB_NAME=your-deployment-name \
-e SDB_TAG=1.1.0 \
-e SDB_KEYWORD=your-keyword \
-e SDB_SLACK_DEFAULT_USER=default-username \
-e SDB_SLACK_GROUP_ID=group-id \
-e SDB_SLACK_GROUP_NAME=group-name \
supinf/envsubst /tmp/.kubernetes/deploy.yaml.tpl) > $(pwd)/.kubernetes/deploy.yamlor use native envsubst
(SDB_SLACK_TOKEN_BASE64=your-token-hash \
SDB_NAME=your-deployment-name \
SDB_TAG=1.1.0 \
SDB_KEYWORD=your-keyword \
SDB_SLACK_DEFAULT_USER=default-username \
SDB_SLACK_GROUP_ID=group-id \
SDB_SLACK_GROUP_NAME=group-name \
envsubst < $(pwd)/.kubernetes/deploy.yaml.tpl) $(pwd)/.kubernetes/deploy.yamlAfter that you can change configuration with kubect or edit config map directly from Kubernetes dashboard
kubectl apply -f $(pwd)/.kubernetes/deploy.yaml --namespace slack-duty-botTo enable tests for your fork repository you MUST:
- Create your project in TravisCI for your fork repository
- Add environment variables to Travis-CI project:
DOCKER_NAMESPACEDOCKER_USERDOCKER_PASSWORD
Travis-CI will run test on every push for every ref and build docker image and push to docker hub ONLY FOR TAGS