Skip to content

Commit

Permalink
Merge pull request #16 from h3poteto/readme
Browse files Browse the repository at this point in the history
Add README
  • Loading branch information
h3poteto authored Mar 8, 2020
2 parents 644923b + 463dc1a commit 9eb1fa3
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 2 deletions.
111 changes: 111 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
![Docker Pulls](https://img.shields.io/docker/pulls/h3poteto/slack-rage)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/h3poteto/slack-rage)](https://github.com/h3poteto/slack-rage/releases)

# SlackRage

SlackRage is a Slack bot. It will monitor all messages in participating channels and detects conversational excitement on these channels. It will notify the channel when excitement is detected.
This command line tool provides two methods to monitor Slack channels. First one is using RTM, and another one is using Slack Event API.

## Usage

```
$ ./slack-rage --help
Notify the rage of slack channel
Usage:
slack-rage [command]
Available Commands:
event Run webhook server for slack Event API
help Help about any command
rtm Run bot using Real Time Message
version Print the version number
Flags:
-h, --help help for slack-rage
```

If you want to use RTM, please provide argument:

```
$ ./slack-rage rtm --help
Run bot using Real Time Message
Usage:
slack-rage rtm [flags]
Flags:
-c, --channel string Notify channel. (default random)
-h, --help help for rtm
-p, --period int Observation period seconds for rage judgement. This CLI notify when there are more than threshold posts per period. (default 60)
-t, --threshold int Threshold for rage judgement. (default 10)
-v, --verbose Enable verbose mode
```

- `channel` Please specify Slack channel name which you want to be notified.
- `period` Observation period seconds.
- `threshold` This CLI notify when there are more than threshold posts per period in a channel.

And `event` command requires same arguments.

## Setup
You can run this CLI with docker, and start bot using RTM as default.

```
$ docker run --rm h3poteto/slack-rage ./slack-rage rtm
```

### RTM
New Slack App [does not support RTM](https://api.slack.com/rtm), so please create [Classic Slack App](https://api.slack.com/apps?new_classic_app=1).

> New Slack apps may not use any Real Time Messaging API method. Create a classic app and use the V1 Oauth flow to use RTM.

After you create a Classic app, you can get `OAuth Access Token` and `Bot User OAuth Access Token`. Please set these token to environment variables.

```
$ docker run --rm -e SLACK_TOKEN={BotUserOAuthAccessToken} -e OAUTH_TOKEN=${OAuthAccessToken} h3poteto/slack-rage
```

And please provide these scopes to the app.

- `bot`
- `channels:history`
- `channels:read`
- `chat:write:bot`
- `user:read`


![rtm-scopes](./readme/rtm-scopes.png)


Everything ok, please invite this bot user to Slack channels which you want to monitor.


### Event API
Please create a new [Slack App](https://api.slack.com/apps), and you can get `Bot User OAuth Access Token`.
Please set this token to environment variables.

```
$ docker run --rm -e SLACK_TOKEN={BotUserOAuthAccessToken} h3poteto/slack-rage event
```

You have to prepare Web server to receive webhook from Slack Event API. So please run this docker image in your server, and assign DNS, like `slack-rage.example.com`.
And please set it to RequestURL in Event Subscriptions.

![event-subscription](./readme/event-subscription.png)

Please provide these scopes to the app.

- `channels:history`
- `channels:read`
- `chat:write`
- `users:read`

![event-scopes](./readme/event-scopes.png)

Everything ok, please invite this bot user to Slack channels which you want to monitor.


## License
The package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
2 changes: 1 addition & 1 deletion cmd/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func runEventCmd() *cobra.Command {
flags := cmd.Flags()
flags.IntVarP(&r.threshold, "threshold", "t", 10, "Threshold for rage judgement.")
flags.IntVarP(&r.period, "period", "p", 60, "Observation period seconds for rage judgement. This CLI notify when there are more than threshold posts per period.")
flags.StringVarP(&r.channel, "channel", "c", "", "Notify channel.")
flags.StringVarP(&r.channel, "channel", "c", "random", "Notify channel.")
flags.BoolVarP(&r.verbose, "verbose", "v", false, "Enable verbose mode")

return cmd
Expand Down
2 changes: 1 addition & 1 deletion cmd/rtm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func runRTMCmd() *cobra.Command {
flags := cmd.Flags()
flags.IntVarP(&r.threshold, "threshold", "t", 10, "Threshold for rage judgement.")
flags.IntVarP(&r.period, "period", "p", 60, "Observation period seconds for rage judgement. This CLI notify when there are more than threshold posts per period.")
flags.StringVarP(&r.channel, "channel", "c", "", "Notify channel.")
flags.StringVarP(&r.channel, "channel", "c", "random", "Notify channel.")
flags.BoolVarP(&r.verbose, "verbose", "v", false, "Enable verbose mode")

return cmd
Expand Down
Binary file added readme/event-scopes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/event-subscription.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme/rtm-scopes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9eb1fa3

Please sign in to comment.