Sha256: ceafcefd2ca1355159380c349c2be0abba337a0ec6f372e34ce6c1e5584b0b67

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

Example of use :

require 'xmppbot'

class Johnny5 < XMPPBot::Bot  
  def connect
    super do |status|
      if status == XMPPBot::ConnectionEvents::CONNECT
        announce_presence
        register_callbacks
      else
        disconnect
      end
    end  
  end
  
  def register_callbacks
    on_presence_received do |pres|      
      puts "#{pres.from} is now #{pres.to_s}" unless pres.to_s.strip == 
""
    end
      
    on_message_received do |msg|
      if msg.body == "exit"
        disconnect
      else
        stanza=XMPPBot::Message.new
        stanza.to=msg.from
        stanza.body="You said : #{msg.body}"
        send(stanza)
      end
    end  
  end
end

@bot = Johnny5.new
@bot.jid = "cripes@jaim.at"
@bot.password = "cripes"
@bot.log_level = XMPPBot::Logging::INFO
@bot.auto_accept_subscriptions = true

@bot.connect

#We pause the execution of the current thread to prevent the program 
from exiting
Thread.stop

#Once the parsing thread exits, execution resumes here
puts "Connection terminated"






For more information on xmppbot, see http://xmppbot.rubyforge.org

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xmppbot-0.0.1 PostInstall.txt
xmppbot-0.0.2 PostInstall.txt
xmppbot-0.0.3 PostInstall.txt