#slack #messages #bot #routing #forward #definition

bin+lib telescreen

A slack bot to forward messages by simple routing definition

3 releases

Uses old Rust 2015

0.1.3 May 20, 2017
0.1.2 May 20, 2017
0.1.0 May 7, 2017

#27 in #forward

MIT license

16KB
315 lines

telescreen

Build Status

telescreen is a Slack bot to forward messages between channels by simple routing definition file.

This screen shot shows the behavior when you use following config.

- match: 'personal-.+'
  destinations:
    - personal-timeline
- match: '.*'
  destinations:
    - public-timeline

Quick start

🔧 Pre-built binary

You can download a pre-built binary from the GitHub release page for Linux and macOS. The binary for only Linux version is linked statically.

🌱 Build on your environment

If you are Rust programmer, you can isntall with cargo command,

$ cargo install telescreen

or also can build manually,

$ git clone git@github.com:mozamimy/telescreen.git
$ cd telescreen
$ cargo build --release
$ ./target/release/telescreen --help
Usage: ./target/debug/telescreen [options]

Options:
    -a, --api-key API_KEY
                        Slack API key for bot integration
    -c, --config FILE   Path to config file
    -h, --help          Print this help menu

In addition, you can build a static linked binary with muslrust Docker image.

$ docker pull clux/muslrust
$ ./exec_with_muslrust cargo build --release

📃 Create a config file

Routing rules are configurable with a file formatted as YAML. The file consits an array contains hashes like { match: regex, destinations: [channel1, channel2, ... ] }.

For example, following config sends all messages to #public-timeline channel.

- match: '.*'
  destinations:
    - public-timeline

On the other hand, following example also sends all messages to #public-timeline channel and sends messages posted to channels that has personal- prefix to #personal-timeline channel.

- match: 'personal-.+'
  destinations:
    - personal-timeline
- match: '.*'
  destinations:
    - public-timeline

🚀 Run

You can run telescreen like following command,

$ telescreen --api-key=[API_KEY] --config=/path/to/your/config

🐳 Run with Docker

The image is hosted in Docker Hub mozamimy/telescreen.

$ git clone git@github.com:mozamimy/telescreen.git
$ cd telescreen
$ API_KEY=[API_KEY] DEST_CHANNEL=your-channel docker-compose up
$ docker-compose down

You can configure through environment variables,

  • API_KEY: Slack API key of Bot integration (required)
  • DEST_CHANNEL: Destination channel (default: general)

It behaves just collect messages and send to DEST_CHANNEL, simply. You should create your own config and use it in the container if you want to use more complicated config.

✒️ Logging

You can specify log level with RUST_LOG environment variable. Following keywords are available,

  • trace
  • debug
  • info
  • warn
  • error (default)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mozamimy/telescreen.

License

The program is available as open source under the terms of the MIT License.

Dependencies

~15–22MB
~369K SLoC