Sha256: 8245d714243e3a7f0b246d2975d78a705d3d731d45241f418459d9f6b3d85cf1
Contents?: true
Size: 771 Bytes
Versions: 27
Compression:
Stored size: 771 Bytes
Contents
#!/usr/bin/ruby # This bot will reply to every message it receives. To end the game, send 'exit' require 'xmpp4r/client' include Jabber # settings if ARGV.length != 2 puts "Run with ./echo_thread.rb user@server/resource password" exit 1 end myJID = JID.new(ARGV[0]) myPassword = ARGV[1] cl = Client.new(myJID) cl.connect cl.auth(myPassword) cl.send(Presence.new) puts "Connected ! send messages to #{myJID.strip.to_s}." mainthread = Thread.current cl.add_message_callback do |m| if m.type != :error m2 = Message.new(m.from, "You sent: #{m.body}") m2.type = m.type cl.send(m2) if m.body == 'exit' m2 = Message.new(m.from, "Exiting ...") m2.type = m.type cl.send(m2) mainthread.wakeup end end end Thread.stop cl.close
Version data entries
27 entries across 27 versions & 5 rubygems