Steam
Ruby Client for Steam.
Installation
Add this line to your application's Gemfile:
gem 'steam'
And then execute:
$ bundle
Or install it yourself as:
$ gem install steam
Usage
To use you may subscribe a listener class to the Steam Client object in order to react to events it fires.
require 'steam'
class MyClient < Steam::Client
def initialize(username, password)
super
@username = username
@password = password
@token = nil
file = SentryFile.new
@sha = file.read
end
def ready
steam_user.login(@username, @password, @token, @sha)
end
def on_logon(msg)
case msg.body.eresult
when EResult::OK
# logged in
when EResult::ACCOUNT_LOGON_DENIED
puts 'Input token'
@token = STDIN.gets.chomp
restart
sleep 5
else
raise "Error: #{msg.body.eresult}"
end
end
end
bot = MyClient.new
bot.start
You may add game specific APIs by including them as a gem. CSGO plugin is provided by fastpeek/steam-csgo
.
class MyClient < Steam::Client
def initialize(username, password)
super
@username = username
@password = password
@token = nil
file = SentryFile.new
@sha = file.read
end
def ready
steam_user.login(@username, @password, @token, @sha)
end
def csgo_match_info(match_info)
# do something with match_info
end
def csgo_ready
csgo.request_match_info(3_176_070_719_880_560_711,
3_176_076_024_165_171_409,
39_898)
end
def on_logon(msg)
case msg.body.eresult
when EResult::OK
csgo.start
when EResult::ACCOUNT_LOGON_DENIED
puts 'Input token'
@token = STDIN.gets.chomp
restart
else
raise "Error: #{msg.body.eresult}"
end
end
end
bot = MyClient.new
bot.plugin(:csgo)
bot.start
Running the tests
To run the integration tests you must specify a Steam username and password. For the plugin integration test to pass this account must have CS:GO installed.
STEAM_LOG_LEVEL=DEBUG USERNAME=username PASSWORD=password rake spec:all