class Eye::Notify::EyeSlack
Constants
- VERSION
Public Instance Methods
execute()
click to toggle source
# File lib/eye/notify/eye_slack.rb, line 29 def execute say(parse_message) end
Private Instance Methods
client()
click to toggle source
# File lib/eye/notify/eye_slack.rb, line 46 def client opts = { username: username } ::Slack::Notifier.new webhook_url, opts end
msg_time()
click to toggle source
# File lib/eye/notify/eye_slack.rb, line 42 def msg_time Eye::Utils.human_time2(msg_at) end
parse_message()
click to toggle source
# File lib/eye/notify/eye_slack.rb, line 35 def parse_message %w{time host message name full_name pid level}.each do |variable| message.gsub!("##{variable}#", send("msg_#{variable}").to_s) if message =~ /##{variable}#/ end message end
say(what)
click to toggle source
# File lib/eye/notify/eye_slack.rb, line 54 def say(what) client.channel = contact data = { attachments: [ { title: title, text: what, color: color, mrkdwn_in: [:text, :title] } ] } if icon data[:icon_emoji] = icon if icon =~ /\A:[^:]*:\Z/ data[:icon_url] = icon if icon =~ /\Ahttp[s]?:\/\/.*/i end client.ping '', data end