Skip to content

Instantly share code, notes, and snippets.

@rogerleite
Created February 17, 2012 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerleite/1854417 to your computer and use it in GitHub Desktop.
Save rogerleite/1854417 to your computer and use it in GitHub Desktop.
Robo xexelento que executa comando
require 'rubygems'
require 'xmpp4r-simple'
# gem install xmpp4r-simple
include Jabber
#Jabber::debug = true
jid = 'email@gmail.com'
pass = 'secret'
jabber = Simple.new(jid, pass)
loop do
messages = jabber.received_messages
messages.each do |message|
next unless message.type == :chat
body = message.body
result = "oi?"
if body.start_with?("$")
process = IO.popen(body.gsub("$", "").strip)
result = process.readlines
end
puts "#{message.from}: #{body}"
puts "#{result}\n"
jabber.deliver(message.from, result)
end
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment