class Notifyou

@author hienvd @date 20151006

Constants

VERSION

Public Class Methods

new(url) click to toggle source

specify a slack webhook url

# File lib/notifyou.rb, line 9
def initialize url
  @slack_url = url
end

Public Instance Methods

notify(msg, channel) click to toggle source

Notify a message to a channel/user

# File lib/notifyou.rb, line 14
def notify msg, channel 
  if @slack_url == '' 
    puts "No slack webhook url specified"
    return
  end

  hash = {:text => msg, :channel => channel}
  json = JSON.generate(hash)
  payload = "payload=#{json}"

  `curl -X POST --data-urlencode '#{payload}' #{@slack_url}`
end