README.md in slack-bot-manager-0.1.0pre1 vs README.md in slack-bot-manager-0.1.0pre2

- old
+ new

@@ -1,28 +1,48 @@ # Slack Bot Manager +[![Gem Version](https://badge.fury.io/rb/slack-bot-manager.svg)](http://badge.fury.io/rb/slack-bot-manager) +[![Build Status](https://travis-ci.org/betaworks/slack-bot-manager.svg?branch=master)](https://travis-ci.org/betaworks/slack-bot-manager) +[![Code Climate](https://codeclimate.com/github/betaworks/slack-bot-manager/badges/gpa.svg)](https://codeclimate.com/github/betaworks/slack-bot-manager) + Slack Bot Manager is a Ruby gem that allows for the management of multiple Slack RTM connections based on tokens. With only a few configuration changes, you can run a system for handling hundreds of simulatenous RTM connections for your Slack app. +_This is in pre-release and may change before release of version 0.1.0._ -## Installation +__How to tell if you need this:__ -While this has yet to be compiled to a Ruby gem, it can be installed from this repository within your Gemfile: +* You are making a Slack app requiring Real-time Messaging +* You want to be able to handle multiple RTM connections +* You don't want to make your own RTM (websocket) connection manager -`gem 'slack-bot-manager', github: 'betaworks/slack-bot-manager', branch: 'master'` -__**This gem requires `redis` for tracking the status of tokens.**__ -You will need to have `redis` running for this gem to work. +## Installation +`gem 'slack-bot-manager'` +This gem requires a key-value storage system for managing tokens and connection statuses. Currently, this gem supports `redis` and `dalli` (memcached). +``` +gem 'redis' +gem 'dalli' +``` + + ## Getting Started -(TODO) +To get started, get a token (or few) and start your script. +``` +botmanager = SlackBotManager::Manager.new +botmanager.add_token('token1', 'token2', 'token3') +botmanager.start +botmanager.monitor +``` + ## Running the Slack Bot Manager Once you initialize a new `SlackBotManager::Manager`, you can use the following connection and token methods to run your cool new Slack bot app. @@ -47,11 +67,11 @@ `monitor` | Run the manager in a continuous loop, checking for changes in connections and token statuses. ### Token Management Methods -Tokens are managed within Redis. SlackBotManager will manage and monitor these redis keys for additions, updates, and remvoals. New connections must be added into the redis `teams_key`, like so: +Tokens are managed using key storage, currently only supporting Redis. SlackBotManager will manage and monitor these keys for additions, updates, and removals. New connections will be added into the key `teams_key`, like so: ``` botmanager = SlackBotManager::Manager.new botmanager.add_token('token1', 'token2', 'token3') # takes array ``` @@ -74,11 +94,11 @@ The following instance variables are accessible by Client and the included Commands module: variable | description --------------|---------------------------------------------------------------------------------------- `connection` | `Slack::RealTime::Client` connection -`id` | Team's Slack ID (ex. `T123ABC`) +`id` | Team's Slack ID (ex. `T123ABC`) _(set after successful connection)_ `token` | Team's Slack access token (ex. `xoxb-123abc456def`) `status` | Known connection status. (`connected`, `disconnected`, `rate_limited`, `token_revoked`) ### Adding Event Listeners @@ -112,31 +132,61 @@ setting | description ------------------|----------------------------------------------------------------------------------- `tokens_key` | Redis key name for where tokens' status are stored. _(default: tokens:statuses)_ `teams_key` | Redis key name for where teams' tokens are stored. _(default: tokens:teams)_ `check_interval` | Interval (in seconds) for checking connections and tokens status. _(default: 5)_ -`redis` | Define Redis connection. _(default: Redis.new)_ +`storage_method` | Token storage method. _(default: nil)_ +`storage_options` | Token storage method options. _(default: {})_ `logger` | Define the logger to use. _(default: Rails.logger or ::Logger.new(STDOUT))_ `log_level` | Explicity define the logger level. _(default: ::Logger::WARN)_ `verbose` | When true, set `log_level` to ::Logger::DEBUG. _(default: false)_ You can define these configuration options as: ``` SlackBotManager::Manager.configure do |config| - config.redis = Redis.new(host: '0.0.0.0', port: 6379) + config.storage_method = SlackBotManager::Storage::Redis + config.storage_options = {host: '0.0.0.0', port: 6379} config.check_interval = 10 # in seconds end ``` +You can additionally send an existing storage method as the `storage_option`, such as: + +``` +SlackBotManager::Manager.configure do |config| + config.storage_options = $redis # Existing Redis connection, where $redis = Redis.new +end +``` + +### Client configuration options + +setting | description +------------------|----------------------------------------------------------------------------------- +`logger` | Define the logger to use. _(default: Rails.logger or ::Logger.new(STDOUT))_ +`log_level` | Explicity define the logger level. _(default: ::Logger::WARN)_ +`verbose` | When true, set `log_level` to ::Logger::DEBUG. _(default: false)_ + +You can define these configuration options as: + +``` +SlackBotManager::Client.configure do |config| + config.check_interval = 10 # in seconds + config.log_level = ::Logger::INFO +end +``` + + +### Additional configuration options + For customization of Slack connections, including proxy, websocket ping, endpoint, user-agent, and more, check out the [slack-ruby-client README](https://github.com/dblock/slack-ruby-client/blob/master/README.md). ## Examples -(TODO) +You can check a few creative examples in the [examples](examples/) folder. ## History @@ -148,9 +198,10 @@ ## Contributing See [CONTRIBUTING](CONTRIBUTING.md). +Thanks to our contributors [Greg Leuch](https://gleu.ch) and [Alex Baldwin](http://goose.im). ## Copyright and License Copyright (c) 2016 [Greg Leuch](https://gleu.ch) & [betaworks](https://betaworks.com).