Guest User

Untitled

a guest
May 24th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. require 'rubygems'
  2. require 'xmpp4r/client'
  3. include Jabber
  4.  
  5. class Callbacky < Client
  6. def initialize *args
  7. super *args
  8. add_message_callback {|m| on_message m }
  9. end
  10.  
  11. def auth *args
  12. super *args
  13. connection_made
  14. end
  15.  
  16. def connection_made
  17. end
  18.  
  19. def on_message
  20. end
  21. end
  22.  
  23. class EchoBot < Callbacky
  24. def connection_made
  25. send Presence.new
  26. end
  27.  
  28. def on_message msg
  29. if msg.type == :chat && msg.body != nil
  30. send Message.new(msg.from, "echo: " + msg.body).set_type(msg.type)
  31. end
  32. end
  33. end
  34.  
  35. client = EchoBot.new JID.new("bot@example.net/echo")
  36. client.connect.auth "wonttell"
  37. Thread.stop
Add Comment
Please, Sign In to add comment