Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Slack fix #178

merged 3 commits into from

2 participants


Slack handler was not properly notifying a channel as this seemed to be using an older version of the slack api maybe? I have created an update to use the slack channel as per the documentation and also have updated it to ensure names are linked.

I have added 2 additional features to the slack notifer as well which allow you to specify the name that appears when notifying the channel (this overrides the default name configured in slack for the token) and added the ability to specify an emoji icon for the notification (which also overrides the default in slack).

These two additions are helpful and make it easier to use a single token across multiple use cases for integrations.

danshultz added some commits
@danshultz danshultz fix slack handler
* Channel should be passed as a body argument
* Include link names to ensure channel properly notified
@danshultz danshultz include ability to set bot username 584549d
@danshultz danshultz slack notifier supports emoji fc13337

Looks good.

@eric eric merged commit d78b312 into mojombo:master

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 1, 2014
  1. @danshultz

    fix slack handler

    danshultz committed
    * Channel should be passed as a body argument
    * Include link names to ensure channel properly notified
  2. @danshultz
  3. @danshultz
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 5 deletions.
  1. +11 −4 lib/god/contacts/slack.rb
  2. +1 −1  test/test_slack.rb
15 lib/god/contacts/slack.rb
@@ -19,7 +19,7 @@ module Contacts
class Slack < Contact
class << self
- attr_accessor :account, :token, :channel, :notify_channel, :format
+ attr_accessor :account, :token, :channel, :notify_channel, :format, :username, :emoji
end = "#general"
@@ -33,7 +33,7 @@ def valid?
- attr_accessor :account, :token, :channel, :notify_channel, :format
+ attr_accessor :account, :token, :channel, :notify_channel, :format, :username, :emoji
def text(data)
text = ""
@@ -63,7 +63,7 @@ def notify(message, time, priority, category, host)
def api_url
- URI.parse("https://#{arg(:account)}{arg(:token)}&channel=#{arg(:channel)}")
+ URI.parse("https://#{arg(:account)}{arg(:token)}")
def request(text)
@@ -71,7 +71,14 @@ def request(text)
http.use_ssl = true
req =
- req.body = { :text => text }.to_json
+ req.body = {
+ :link_names => 1,
+ :text => text,
+ :channel => arg(:channel)
+ }.tap { |payload|
+ payload[:username] = arg(:username) if arg(:username)
+ payload[:icon_emoji] = arg(:emoji) if arg(:emoji)
+ }.to_json
res = http.request(req)
2  test/test_slack.rb
@@ -16,7 +16,7 @@ def setup
def test_api_url
- assert_equal "", @slack.api_url.to_s
+ assert_equal "", @slack.api_url.to_s
def test_notify
Something went wrong with that request. Please try again.