Skip to content

Instantly share code, notes, and snippets.

@andion
Created December 22, 2010 09:44
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 andion/751321 to your computer and use it in GitHub Desktop.
Save andion/751321 to your computer and use it in GitHub Desktop.
Similar lottery-check script to https://gist.github.com/751314 but only print something if you've won something
#!/usr/bin/env ruby
url = 'http://api.elpais.com/ws/LoteriaNavidadPremiados?n='
urls = {}
if ARGV.any?
ARGV.each do |n|
urls[n] = "#{url}#{n.to_i}"
end
espera = 0
while true
sleep n = 5
if (espera+= n) >= 120
puts "Son las #{Time.now.strftime("%H:%M")} y todavía no ha tocado nada :("
espera = 0
end
urls.each do |n,u|
premio = `curl -s #{u}`.split(',')[1].split(':')[1]
5.times {puts "PREMIADO TU NÚMERO #{n} con #{premio} euros!!!!!"} if premio != '0'
end
end
else
puts '\nUSAGE: loteria_navidad numero1 [numero2,numero3,...]\n'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment