module MiscCommands::Misc_ClassMethods
Public Instance Methods
partner_id_to_steam_id(account_id)
click to toggle source
# File lib/Misc.rb, line 117 def partner_id_to_steam_id(account_id) unknown_constant = 17825793 # or 0x1100001 idk wtf is this but .... first_bytes = [account_id.to_i].pack('i>') last_bytes = [unknown_constant].pack('i>') collect = last_bytes + first_bytes return collect.unpack('Q>')[0].to_s end
Private Instance Methods
output(message)
click to toggle source
# File lib/Misc.rb, line 126 def output(message) time = Time.new add = time.strftime("%d-%m-%Y %H:%M:%S") puts "#{add} :: #{message}" end
verify_profileid_or_trade_link_or_steamid(steamid)
click to toggle source
# File lib/Misc.rb, line 132 def verify_profileid_or_trade_link_or_steamid(steamid) if steamid.to_i == 0 && steamid.include?("?partner=") ##supplied trade link partner_raw = steamid.split('partner=',2)[1].split('&',2)[0] token = steamid.split('token=', 2)[1] steamid = partner_id_to_steam_id(partner_raw) return [steamid,token] elsif steamid.to_i == 0 session = Mechanize.new parser = Nokogiri::XML(session.get("https://steamcommunity.com/id/#{steamid}?xml=1").content) if parser.xpath('//error').text == ('The specified profile could not be found.') raise "No profile with #{steamid} as profileid" end steamid = parser.xpath('//steamID64').text return steamid elsif steamid.to_s.length == 17 return steamid else raise "invalid steamid : #{steamid}, length of received :: #{steamid.to_s.length}, normal is 17" if steamid.to_s.length != 17 end end