Slack::Ruby

A Ruby interface to Slack API.

Installation

Add this line to your application's Gemfile:

gem 'slack-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slack-ruby

Usage

How to use RPC-Style Web API

require "slack"

# create RPC client object with OAuth token
client = Slack::RPC::Client.new("xxxx-xxxxxxxxx-xxxx")

# or you can set OAuth token after initialization
client = Slack::RPC::Client.new()
client.token = "yyyy-yyyyyyyyy-yyyy"

# execute RPC command and retrieve response
client.channels.archive(:channel => "C1234567890") do |response|
  # your own code
end

# or you can get response as returned object
response = client.channels.archive(:channel => "C1234567890")
# your own code

RPC command

see Slack Web API Document

Response object

  • Slack::RPC::Response.status is HTTP status code as integer
  • Slack::RPC::Response.headers is HTTP response header as Hash object
  • Slack::RPC::Response.body is HTTP response body as Hash object

How to use Real Time Messaging API

TODO

Contributing

  1. Fork it ( https://github.com/morou/slack-ruby/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request