public
Description: Example of notification classes for Pushr. Heavily inspired by Integrity
Homepage: http://github.com/karmi/pushr/tree/master
Clone URL: git://github.com/karmi/pushr_notifiers.git
pushr_notifiers / jabber.rb
100644 31 lines (22 sloc) 0.738 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rubygems'
require 'xmpp4r'
 
# = Jabber notifications for Pushr (http://github.com/karmi/pushr/)
# Buy http://peepcode.com/products/xmpp from Topfunky!
class Pushr::Notifier::Jabber < Pushr::Notifier::Base
 
  def deliver!(notification)
    return unless configured?
 
    jid = Jabber::JID.new(config['username'])
    client = Jabber::Client.new(jid)
    client.connect
 
    client.auth(config['password'])
    client.send(Jabber::Presence.new.set_status("Pushr at #{Time.now.utc}"))
 
    msg = Jabber::Message.new(config['username'], message(notification))
    msg.type = :normal
    client.send(msg)
 
    client.close
  end
 
  private
 
  def configured?
    !config['username'].nil? && !config['password'].nil?
  end
 
end