module MiscCommands

Public Class Methods

included(base) click to toggle source
# File lib/Misc.rb, line 112
def self.included(base)
     base.extend(Misc_ClassMethods)
end

Public Instance Methods

api_call(request_methode, interface, api_methode ,version,params = nil) click to toggle source
# File lib/Misc.rb, line 94
def api_call(request_methode, interface, api_methode ,version,params = nil)
      url = ["https://api.steampowered.com","#{interface}", "#{api_methode}", "#{version}"].join('/')
      if request_methode.downcase == "get"
            response = @session.get(url, params)
      elsif request_methode.downcase == "post"
            response = @session.get(url,params)
      else
            raise "invalid request methode : #{request_methode}"
      end
      if response.content.include?("Access is denied")
            raise "invalid API_key"
      end
      return response.content
end
copy_session() click to toggle source
# File lib/Misc.rb, line 20
def copy_session()
      return @session
end
output(message) click to toggle source
# File lib/Misc.rb, line 47
def output(message)
      time = Time.new
      add = time.strftime("%d-%m-%Y %H:%M:%S")
      puts "#{add} :: #{@username.to_s} :: #{message}" if message != ''
end
partner_id_to_steam_id(account_id) click to toggle source
# File lib/Misc.rb, line 38
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
set_steamid(steamid) click to toggle source
# File lib/Misc.rb, line 9
def set_steamid(steamid)
      if @loggedin == false
            @steamid,token = verify_profileid_or_trade_link_or_steamid(steamid)
            output "steamID set to #{@steamid}"
      else
            raise "editing steamID while logged in will cause malfunctions"
      end
end
use_chat_session() click to toggle source
# File lib/Misc.rb, line 29
def use_chat_session()
      @chat_session
end
use_session() click to toggle source
# File lib/Misc.rb, line 24
def use_session()
      @session
end