Using XMPP4R--Simple these Ruby code snippets show a user's status change and any messages they may have sent you since the last time.
# user1 changes their status to away
jabber.presence_updates do |friend, old_presence, new_presence|
puts "Received presence update from #{friend.to_s}: #{new_presence}"
end
# user1 sends the message "do you like Tofu?"
jabber.received_messages do |message|
puts "Received message from #{message.from}: #{message.body}"
end
Reference: http://xmpp4r-simple.rubyforge.org/
Read »
