Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'xmpp4r/client'
- include Jabber
- class Callbacky < Client
- def initialize *args
- super *args
- add_message_callback {|m| on_message m }
- end
- def auth *args
- super *args
- connection_made
- end
- def connection_made
- end
- def on_message
- end
- end
- class EchoBot < Callbacky
- def connection_made
- send Presence.new
- end
- def on_message msg
- if msg.type == :chat && msg.body != nil
- send Message.new(msg.from, "echo: " + msg.body).set_type(msg.type)
- end
- end
- end
- client = EchoBot.new JID.new("bot@example.net/echo")
- client.connect.auth "wonttell"
- Thread.stop
Add Comment
Please, Sign In to add comment