slack-notify
Send notifications to Slack
Installation
Add this line to your application's Gemfile:
gem "slack-notify"
And then execute:
$ bundle
Or install it yourself as:
$ gem install slack-notify
Usage
Require:
require "slack-notify"
Initialize client:
client = SlackNotify::Client.new("team", "token")
Initialize with options:
client = SlackNotify::Client.new("team", "token", {
channel: "#development",
username: "mybot",
icon_url: "http://mydomain.com/myimage.png",
icon_emoji: ":shipit:"
})
Send test request:
client.test
Send message:
client.notify("Hello There!")
client.notify("Another message", "#channel2")
client.notify("Message", ["#channel1", "#channel2"])
Send direct message:
client.notify("Hello There!", "@username")
You can also test gem via rake console:
rake console
Gotchas
Current issues with Slack API:
- No message raised if team subdomain is invalid
- 500 server error is raised on bad requests
License
Copyright (c) 2013-2014 Dan Sosedoff, [email protected]
MIT License