Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require "rubygems"
- require "xmpp4r-simple"
- require "session"
- ADMIN = "sebcioz@gmail.com" # adres klienta
- AUTHORIZATION_PASSWORD = "test" # hasło autoryzacyjne, należy podać jako pierwszą wiadomość
- CLIENT = "sebcioz@v-lo.krakow.pl" # adres deamona
- CLIENT_PASSWORD = "***" # hasło deamona
- im = Jabber::Simple.new(CLIENT, CLIENT_PASSWORD)
- im.deliver(ADMIN, "Hey, it works!")
- loop do
- im.received_messages do |msg|
- if @sh
- stdout, stderr = @sh.execute(msg.body)
- im.deliver(ADMIN, stdout.to_s.chomp) unless msg.body.empty?
- im.deliver(ADMIN, "[#{@sh.execute("pwd").to_s.chomp}] > ")
- puts msg.body if msg.body
- else
- if msg.body == AUTHORIZATION_PASSWORD
- @sh = Session::new
- im.deliver(ADMIN, "Authorization complete!")
- end
- end
- end
- sleep 1
- end
Add Comment
Please, Sign In to add comment