Slack Poster
Slack is a mashup of chatrooms and collaborative sharing tools that are meant to do away with redundant conversations in multiple places.
slack-poster is a simple gem to make your integration with Slack easier. It supports only incoming communications (from you to Slack).
Installation
Add this line to your application's Gemfile:
$ gem 'slack-poster'
And then execute:
$ bundle
Or install it yourself as:
$ gem install slack-poster
Usage
First, you need to create an Incoming Webhook integration at https://team-name.slack.com/services/new/incoming-webhook and take note of the generated token.
Next, create a new poster and send the message:
TEAM = 'team-name'
TOKEN = 'hd7heoo2oijd0'
poster = Slack::Poster.new(TEAM, TOKEN)
poster.send_message('Hello, world!')
You can use an options array if you don't want to use the settings configured directly on Slack:
options = {
icon_url: 'http://example.com/image.png',
# or icon_emoji: 'emoji_name',
username: 'Tester',
channel: '#random'
}
And then use it as a third parameter. Note that every option is optional (no pun intended!).
poster = Slack::Poster.new(TEAM, TOKEN, options)
poster.send_message('Hi!') # will send to #random with the username 'Tester'
That's it!
Contributing
- Fork it ( http://github.com/rikas/slack-poster/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