Class: AlertSlack

Inherits:
Object
  • Object
show all
Defined in:
lib/alert/slack.rb

Overview

Email alert class Uses localhost for sending email - Probably need to change this in the future.

Instance Method Summary collapse

Instance Method Details

#send(slack_url, slack_channel, body) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/alert/slack.rb', line 8

def send(slack_url, slack_channel, body)

  payload = Hash[
              'channel', slack_channel,
              'text', body.to_json,
]

RestClient.post slack_url, payload.to_json, {content_type: :json}

rescue Errno::ECONNREFUSED
  puts "*** Conection refused while attempting to connect to SMTP server\n" \
       "*** Recipient, #{@destination}. Body,\n" \
       "*** #{@body}\n"
end