Skip to content

Instantly share code, notes, and snippets.

@visnup
Created February 26, 2009 08:54
Show Gist options
  • Save visnup/70743 to your computer and use it in GitHub Desktop.
Save visnup/70743 to your computer and use it in GitHub Desktop.
xmpp4r + say
# login to jabber/gtalk and have your computer say whatever people are saying to you
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
id, pass = JID.new(ARGV[0]), ARGV[1]
cl = Client.new id
cl.connect
cl.auth pass
cl.send Presence.new
puts id.strip.to_s
mainthread = Thread.current
cl.add_message_callback do |m|
if m.type != :error
puts m.body
`say "#{m.body}"`
if m.body == 'exit'
mainthread.wakeup
end
end
end
Thread.stop
cl.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment