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

- old
+ new

@@ -67,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 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: +Tokens are managed using the defined storage adapter (Redis or Dalli). 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 ``` @@ -97,12 +97,26 @@ --------------|---------------------------------------------------------------------------------------- `connection` | `Slack::RealTime::Client` connection `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`) +`storage` | Storage adapter from Config. +### Client Methods + +These are some common client methods you can use to manage incoming events and interact with Slack. + +methods | description +-----------------------------|---------------------------------------------------------------------------------------- +`message(channel, text, {})` | Send a message to channel. Handles both simple RTM message or chat.postMessage if additional options are present. +`typing(channel, {})` | Send typing notification. +`ping({})` | Send a manual ping to Slack. +`on(event, &block)` | Add an event listener. (Same as extending with `on_*` methods.) +`off(event, &block)` | Remove an event listener. (Does not remove defined `on_*` methods.) + + ### Adding Event Listeners You will want to handle your own RTM event listeners to perform specific functions. This is achieved by extending the `SlackBotManager:Commands` module, which is included within the `SlackBotManager::Client` class (and access to subsequent instance variables specific to that connection). Each event must be prefixed with `on_`, e.g. `on_messsage` will handing incoming messages. @@ -113,11 +127,11 @@ def on_hello(data) puts "Connected to %s" % self.id end def on_team_join(data) - puts "New team member joined: %s" % data['user']['username'] + message(data['channel'], "Welcome: %s" % data['user']['username']) end end end ``` @@ -125,53 +139,66 @@ ## Configuration -### Manager configuration options +### Global configuration options 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)_ -`storage_method` | Token storage method. _(default: nil)_ +`storage_adapter` | 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.configure do |config| + config.storage_adapter = SlackBotManager::Storage::Redis + config.storage_options = {host: '0.0.0.0', port: 6379} +end +``` + +### Manager configuration options + +Manager configuration options include the global options (`storage_adapter`, `storage_options`, `logger`, `log_level`, & `verbose`), in addition to: + + +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)_ + +You can define these configuration options as: + +``` SlackBotManager::Manager.configure do |config| - config.storage_method = SlackBotManager::Storage::Redis + config.storage_adapter = 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: ``` +$redis = Redis.new SlackBotManager::Manager.configure do |config| - config.storage_options = $redis # Existing Redis connection, where $redis = Redis.new + config.storage_options = $redis 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)_ +Client configuration options include the global options (`storage_adapter`, `storage_options`, `logger`, `log_level`, & `verbose`) You can define these configuration options as: ``` SlackBotManager::Client.configure do |config| - config.check_interval = 10 # in seconds config.log_level = ::Logger::INFO end ```