Sha256: 951d33ea4e5f8ddd58db2c01b42af9a161265f99194c192bde148dbf9223ffcc
Contents?: true
Size: 1.06 KB
Versions: 4
Compression:
Stored size: 1.06 KB
Contents
#!/usr/bin/env ruby require 'xmpp4r' module Flapjack module Notifiers class Xmpp def initialize(opts={}) @jid = opts[:jid] @password = opts[:password] @log = opts[:logger] unless @jid && @password raise ArgumentError, "You have to provide a username and password" end begin @xmpp = Jabber::Client.new(@jid) @xmpp.connect @xmpp.auth(@password) rescue SocketError => e @log.error("XMPP: #{e.message}") end end def notify(opts={}) raise ArgumentError, "a recipient was not specified" unless opts[:who] raise ArgumentError, "a result was not specified" unless opts[:result] text = <<-DESC Check #{opts[:result].check_id} returned the status "#{opts[:result].status}". http://localhost:4000/checks/#{opts[:result].check_id} DESC message = Jabber::Message.new(opts[:who].jid, text) @xmpp.send(message) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems