Skip to content

Instantly share code, notes, and snippets.

@ohmree
Created May 12, 2018 22:24
Show Gist options
  • Save ohmree/153922e31e6a12328c6b84a88beb19e7 to your computer and use it in GitHub Desktop.
Save ohmree/153922e31e6a12328c6b84a88beb19e7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'json'
def vote(points)
poss = (1..9).to_s
s1, s2, s3, s4, s5 = ''
xs = Hash.new
def helper() poss[rand(0..(poss.length - 1))] end
def num?(var)
var =~ /[[:digit:]]/
end
(1..5).each do |i|
xs["s#{i}"] = ''
end
xs.take(xs.length - 1).each do |s|
4.times do
s += helper
end
end
12.times { xs["s5"] += helper }
data = {'points': points}
headers = {
'x-esc-uuid': "ffffffff-#{s2}-#{s3}+-#{s4}-#{s5}",
'User-Agent': 'Lightify@ESC, 0.0.5, null, Android 7.0',
'Content-Type': 'application/json; charset=UTF-8',
'Content-Length': '12',
'Host': 'esc-lightify.com',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip'
}
uri = URI.parse 'https://esc-lightify.com/api/vote'
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = data.to_json
res = http.request request
d = JSON.parse response
if res.code == 200
puts "Voted for '#{d['title'].to_s}' with #{points.to_s}' points"
else
puts 'Failed to vote'
end
end
if ARGV.length != 2
puts "USAGE: #{$0} POINTS TIMES"
exit
end
points = ARGV[0]
times = ARGV[1]
if not points =~ /[[:digit:]]/
puts "Points between 1 and 12"
elsif not times =~ /[[:digit:]]/
puts "Times is a number"
else
exit
end
points = points.to_i
times = times.to_i
0..times.times { vote points }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment