Sha256: 6e8d8183ad868546d7feb0b8ea67cf05251dafd9f0f562c8a7d1ea30abf58eae
Contents?: true
Size: 790 Bytes
Versions: 37
Compression:
Stored size: 790 Bytes
Contents
#!/usr/bin/ruby # This bot will reply to every message it receives. To end the game, send 'exit' require 'rubygems' 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
37 entries across 37 versions & 2 rubygems