Class: Notifyou
- Inherits:
-
Object
- Object
- Notifyou
- Defined in:
- lib/notifyou.rb,
lib/notifyou/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
-
#initialize(url) ⇒ Notifyou
constructor
specify a slack webhook url.
-
#notify(msg, channel) ⇒ Object
Notify a message to a channel/user.
Constructor Details
#initialize(url) ⇒ Notifyou
specify a slack webhook url
9 10 11 |
# File 'lib/notifyou.rb', line 9 def initialize url @slack_url = url end |
Instance Method Details
#notify(msg, channel) ⇒ Object
Notify a message to a channel/user
14 15 16 17 18 19 20 21 22 23 24 25 |
# 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 |