Method: God::Contacts::Jabber#notify

Defined in:
lib/god/contacts/jabber.rb

#notify(message, time, priority, category, host) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/god/contacts/jabber.rb', line 39

def notify(message, time, priority, category, host)
  begin
    jabber_id = XMPP4R::JID::new "#{Jabber.settings[:jabber_id]}/God"
    jabber_client = XMPP4R::Client::new jabber_id
    jabber_client.connect
    jabber_client.auth Jabber.settings[:password]

    body = Jabber.format.call message, priority, category, host
    
    message = XMPP4R::Message::new self.jabber_id, body
    message.set_type :normal
    message.set_id '1'
    message.set_subject 'God'
    jabber_client.send message

    self.info = "sent jabber message to #{self.jabber_id}"
  rescue => e
    puts e.message
    puts e.backtrace.join("\n")
    
    self.info = "failed to send jabber message to #{self.jabber_id}: #{e.message}"
  end
end