Slack.rb
Ruby toolkit for working with the Slack API
Installation
Add this line to your application's Gemfile:
gem 'slack'
And then execute:
$ bundle
Or install it yourself as:
$ gem install slack
Usage
Making requests
# Provide authentication credentials
client = Slack::Client.new(team: 'netflower', token: 'xxxx-xxxxxxxxx-xxxx')
# Post a message
client.post_message("May the force be with you", "yoda-quotes")
# List all channels
client.channels
Configuration and defaults
Configuring module defaults
Every writable attribute in {Slack::Configurable} can be set one at a time:
Slack.api_endpoint = 'https://slack.dev/api'
Slack.default_channel = '#lol-cats'
Slack.username = 'Yoda'
or in batch:
Slack.configure do |c|
c.api_endpoint = 'https://slack.dev/api'
c.default_channel = '#lol-cats'
c.username = 'Yoda'
end
Using ENV variables
Default configuration values are specified in {Slack::Default}. Many attributes will look for a default value from the ENV before returning Slack's default.
# Given $SLACK_API_ENDPOINT is "https://slack.dev/api"
Slack.api_endpoint
# => "https://slack.dev/api"
Contributing
- Fork it ( http://github.com/netflower/slack.rb/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request