Sha256: acec06d16b01ea0a066744d20387cb94b65602178604c9d818193a192acff951

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

=begin Adhearsion metadata

=end

require 'xmpp4r-simple'

class MultiMessenger
  
  Format = /\A[\w\._%-]+@[\w\.-]+\.[a-zA-Z]{2,4}\z/
  
  def initialize username, password
    @username, @password = username, password
    @connection = Jabber::Simple.new username, password
  end
  
  def connected?() @connection.connected? end
  def your_username?(un) @username.downcase == un.downcase end
  def your_service?(s) %w'xmpp jabber gtalk'.include? s.to_s.downcase end
  def may_be_yours?(sn) true end
  def im username, message
    #debug "Connection #{@connection.inspect}, UN: #{username}, MSG: #{message}"
    @connection.deliver(username, message)
  end
  attr_reader :connection
end

config = $HELPERS['multi_messenger']

username = config['username']||''
password = config['password']||''

log "MultiMessenger: Connecting to #{username}"
jabber = MultiMessenger.new username, password

InstantMessenger.use_service jabber
$HUTDOWN.hook { jabber.connection.disconnect }

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
adhearsion-0.7.4 apps/default/helpers/multi_messenger.rb
adhearsion-0.7.5 apps/default/helpers/multi_messenger.rb
adhearsion-0.7.6 apps/default/helpers/multi_messenger.rb