Sha256: f5414163d9079453a8214e534af7272af9f29b9deff2ce40a1aab5ab051b07ce
Contents?: true
Size: 1.02 KB
Versions: 21
Compression:
Stored size: 1.02 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
21 entries across 21 versions & 1 rubygems