Created
February 17, 2012 17:09
-
-
Save rogerleite/1854417 to your computer and use it in GitHub Desktop.
Robo xexelento que executa comando
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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