steam-condenser 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/exceptions/packet_format_exception.rb +12 -5
- data/lib/exceptions/rcon_ban_exception.rb +11 -3
- data/lib/exceptions/rcon_no_auth_exception.rb +10 -3
- data/lib/exceptions/steam_condenser_exception.rb +8 -5
- data/lib/exceptions/timeout_exception.rb +13 -3
- data/lib/exceptions/web_api_exception.rb +31 -23
- data/lib/steam-condenser.rb +9 -3
- data/lib/steam-condenser/community.rb +8 -1
- data/lib/steam-condenser/servers.rb +7 -1
- data/lib/steam-condenser/version.rb +2 -1
- data/lib/steam/community/cacheable.rb +4 -4
- data/lib/steam/community/game_inventory.rb +119 -0
- data/lib/steam/community/game_item.rb +38 -0
- data/lib/steam/community/game_stats.rb +10 -4
- data/lib/steam/community/portal2/portal2_inventory.rb +21 -0
- data/lib/steam/community/portal2/portal2_item.rb +35 -0
- data/lib/steam/community/portal2/portal2_stats.rb +28 -0
- data/lib/steam/community/tf2/tf2_inventory.rb +7 -37
- data/lib/steam/community/tf2/tf2_item.rb +8 -79
- data/lib/steam/community/tf2/tf2_stats.rb +10 -13
- data/lib/steam/community/web_api.rb +1 -0
- data/lib/steam/packets/a2m_get_servers_batch2_packet.rb +37 -4
- data/lib/steam/packets/a2s_info_packet.rb +10 -5
- data/lib/steam/packets/a2s_player_packet.rb +16 -6
- data/lib/steam/packets/a2s_rules_packet.rb +16 -4
- data/lib/steam/packets/a2s_serverquery_getchallenge_packet.rb +11 -5
- data/lib/steam/packets/c2m_checkmd5_packet.rb +10 -4
- data/lib/steam/packets/m2a_server_batch_packet.rb +19 -3
- data/lib/steam/packets/m2c_isvalidmd5_packet.rb +14 -5
- data/lib/steam/packets/m2s_requestrestart_packet.rb +14 -4
- data/lib/steam/packets/rcon/rcon_auth_request.rb +15 -3
- data/lib/steam/packets/rcon/rcon_auth_response.rb +17 -3
- data/lib/steam/packets/rcon/rcon_exec_request.rb +15 -3
- data/lib/steam/packets/rcon/rcon_exec_response.rb +20 -3
- data/lib/steam/packets/rcon/rcon_goldsrc_request.rb +18 -3
- data/lib/steam/packets/rcon/rcon_goldsrc_response.rb +17 -3
- data/lib/steam/packets/rcon/rcon_packet.rb +31 -3
- data/lib/steam/packets/rcon/rcon_packet_factory.rb +15 -5
- data/lib/steam/packets/rcon/rcon_terminator.rb +14 -5
- data/lib/steam/packets/request_with_challenge.rb +10 -5
- data/lib/steam/packets/s2a_info2_packet.rb +14 -5
- data/lib/steam/packets/s2a_info_base_packet.rb +16 -6
- data/lib/steam/packets/s2a_info_detailed_packet.rb +15 -8
- data/lib/steam/packets/s2a_logstring_packet.rb +11 -5
- data/lib/steam/packets/s2a_player_packet.rb +14 -6
- data/lib/steam/packets/s2a_rules_packet.rb +15 -5
- data/lib/steam/packets/s2c_challenge_packet.rb +17 -6
- data/lib/steam/packets/s2m_heartbeat2_packet.rb +18 -4
- data/lib/steam/packets/steam_packet.rb +14 -5
- data/lib/steam/packets/steam_packet_factory.rb +25 -2
- data/lib/steam/servers/game_server.rb +154 -25
- data/lib/steam/servers/goldsrc_server.rb +35 -3
- data/lib/steam/servers/master_server.rb +77 -23
- data/lib/steam/servers/server.rb +42 -3
- data/lib/steam/servers/source_server.rb +35 -11
- data/lib/stringio_additions.rb +48 -3
- data/test/query_tests.rb +4 -4
- metadata +11 -6
@@ -1,14 +1,21 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'exceptions/steam_condenser_exception'
|
7
7
|
|
8
|
+
# This exception class indicates a problem when parsing packet data from the
|
9
|
+
# responses received from a game or master server
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
8
12
|
class PacketFormatException < SteamCondenserException
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
# Creates a new `PacketFormatException` instance
|
15
|
+
#
|
16
|
+
# @param [String] message The message to attach to the exception
|
17
|
+
def initialize(message)
|
18
|
+
super message
|
12
19
|
end
|
13
20
|
|
14
21
|
end
|
@@ -1,12 +1,20 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2009-
|
4
|
+
# Copyright (c) 2009-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'exceptions/steam_condenser_exception'
|
7
7
|
|
8
|
+
# This exception class indicates that the IP address your accessing the game
|
9
|
+
# server from has been banned by the server
|
10
|
+
#
|
11
|
+
# You or the server operator will have to unban your IP address on the server.
|
12
|
+
#
|
13
|
+
# @author Sebastian Staudt
|
14
|
+
# @see GameServer#rcon_auth
|
8
15
|
class RCONBanException < SteamCondenserException
|
9
16
|
|
17
|
+
# Creates a new `RCONBanException` instance
|
10
18
|
def initialize
|
11
19
|
super 'You have been banned from this server.'
|
12
20
|
end
|
@@ -1,12 +1,19 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'exceptions/steam_condenser_exception'
|
7
7
|
|
8
|
+
# This exception class indicates that you have not authenticated yet with the
|
9
|
+
# game server you're trying to send commands via RCON
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
12
|
+
# @see GameServer#rcon_auth
|
13
|
+
# @see GameServer#rcon_exec
|
8
14
|
class RCONNoAuthException < SteamCondenserException
|
9
15
|
|
16
|
+
# Creates a new `RCONNoAuthException` instance
|
10
17
|
def initialize
|
11
18
|
super 'Not authenticated yet.'
|
12
19
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
5
|
|
6
|
+
# This exception class is used as a base class for all exceptions related to
|
7
|
+
# Steam Condenser's operation
|
8
|
+
#
|
9
|
+
# @author Sebastian Staudt
|
6
10
|
class SteamCondenserException < StandardError
|
7
|
-
|
8
|
-
end
|
11
|
+
end
|
@@ -1,12 +1,22 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'exceptions/steam_condenser_exception'
|
7
7
|
|
8
|
+
# This exception class indicates that an operation could not be finished within
|
9
|
+
# a reasonable amount of time
|
10
|
+
#
|
11
|
+
# This usually indicates that a server could not be contacted because of
|
12
|
+
# network problems.
|
13
|
+
#
|
14
|
+
# @author Sebastian Staudt
|
15
|
+
# @note {SteamSocket.timeout=} allows to set a custom timeout for socket
|
16
|
+
# operations
|
8
17
|
class TimeoutException < SteamCondenserException
|
9
18
|
|
19
|
+
# Creates a new `TimeoutException` instance
|
10
20
|
def initialize
|
11
21
|
super 'The operation timed out.'
|
12
22
|
end
|
@@ -1,34 +1,42 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c)
|
4
|
+
# Copyright (c) 2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'exceptions/steam_condenser_exception'
|
7
7
|
|
8
|
-
# This
|
9
|
-
# fails. This can have various reasons
|
8
|
+
# This exception is raised when a Steam Web API request or a related action
|
9
|
+
# fails. This can have various reasons like an invalid Web API key or a broken
|
10
|
+
# request.
|
11
|
+
#
|
12
|
+
# @author Sebastian Staudt
|
13
|
+
# @see WebApi
|
10
14
|
class WebApiException < SteamCondenserException
|
11
15
|
|
12
|
-
# Creates a new WebApiException with an error message according to the given
|
13
|
-
#
|
14
|
-
# itself) or
|
15
|
-
# taken from
|
16
|
+
# Creates a new `WebApiException` with an error message according to the given
|
17
|
+
# `cause`. If this cause is `:status_bad` (which will origin from the Web API
|
18
|
+
# itself) or `:http_error` the details about this failed request will be
|
19
|
+
# taken from `status_code` and `status_message`.
|
20
|
+
#
|
21
|
+
# @param [:http_error, :invalid_key, :status_bad, :unauthorized] cause A
|
22
|
+
# symbolic name for the problem which caused this exception:
|
16
23
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# http://steamcommunity.com/dev/apikey.
|
24
|
+
# * `:http_error`: An error during the HTTP request itself will result
|
25
|
+
# in an exception with this reason.
|
26
|
+
# * `:invalid_key`: This occurs when trying to set a Web API key that
|
27
|
+
# isn't valid, i.e. a 128 bit integer in a hexadecimal string.
|
28
|
+
# * `:status_bad`: This is caused by a successful request that fails
|
29
|
+
# for some Web API internal reason (e.g. an invalid argument).
|
30
|
+
# Details about this failed request will be taken from `status_code`
|
31
|
+
# and `status_message`.
|
32
|
+
# * `:unauthorized`: This happens when a Steam Web API request is
|
33
|
+
# rejected as unauthorized. This most likely means that you did not
|
34
|
+
# specify a valid Web API key using {WebAPI.api_key=}. A Web API key
|
35
|
+
# can be obtained from http://steamcommunity.com/dev/apikey.
|
30
36
|
#
|
31
|
-
#
|
37
|
+
# Other undefined reasons will cause a generic error message.
|
38
|
+
# @param [Fixnum] status_code The HTTP status code returned by the Web API
|
39
|
+
# @param [String] status_message The status message returned in the response
|
32
40
|
def initialize(cause, status_code = nil, status_message = '')
|
33
41
|
case cause
|
34
42
|
when :http_error then
|
data/lib/steam-condenser.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2009-
|
4
|
+
# Copyright (c) 2009-2011, Sebastian Staudt
|
5
5
|
|
6
|
+
# This module is used as a wrapper around Steam Condenser's classes
|
7
|
+
#
|
8
|
+
# It does not provide any own functionality, but this file is used as an entry
|
9
|
+
# point when using the gem (i.e. +require 'steam-condenser').
|
10
|
+
#
|
11
|
+
# @author Sebastian Staudt
|
6
12
|
module SteamCondenser
|
7
13
|
|
8
14
|
require 'steam-condenser/community'
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2010, Sebastian Staudt
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
module SteamCondenser
|
7
7
|
|
8
8
|
require 'steam-condenser/version'
|
9
9
|
|
10
|
+
# This module is used as a wrapper around Steam Condenser's Steam Community
|
11
|
+
# classes
|
12
|
+
#
|
13
|
+
# It does not provide any own functionality, but this file is used to easily
|
14
|
+
# require classes to interact with the Steam Community
|
15
|
+
#
|
16
|
+
# @author Sebastian Staudt
|
10
17
|
module Community
|
11
18
|
|
12
19
|
require 'steam/community/steam_id'
|
@@ -1,12 +1,18 @@
|
|
1
1
|
# This code is free software; you can redistribute it and/or modify it under the
|
2
2
|
# terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2010, Sebastian Staudt
|
4
|
+
# Copyright (c) 2010-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
module SteamCondenser
|
7
7
|
|
8
8
|
require 'steam-condenser/version'
|
9
9
|
|
10
|
+
# This module is used as a wrapper around Steam Condenser's server classes
|
11
|
+
#
|
12
|
+
# It does not provide any own functionality, but this file is used to easily
|
13
|
+
# require classes to interact with servers
|
14
|
+
#
|
15
|
+
# @author Sebastian Staudt
|
10
16
|
module Servers
|
11
17
|
|
12
18
|
require 'steam/servers/goldsrc_server'
|
@@ -10,8 +10,8 @@ module Cacheable
|
|
10
10
|
def self.included(base) #:nodoc:
|
11
11
|
|
12
12
|
base.extend ClassMethods
|
13
|
-
base.
|
14
|
-
base.
|
13
|
+
base.send :class_variable_set, :@@cache, {}
|
14
|
+
base.send :class_variable_set, :@@cache_ids, []
|
15
15
|
|
16
16
|
class << base
|
17
17
|
alias_method :create, :new
|
@@ -67,8 +67,8 @@ module Cacheable
|
|
67
67
|
|
68
68
|
# Saves this object in the cache
|
69
69
|
def cache
|
70
|
-
cache = self.class.
|
71
|
-
cache_ids = self.class.
|
70
|
+
cache = self.class.send :class_variable_get, :@@cache
|
71
|
+
cache_ids = self.class.send :class_variable_get, :@@cache_ids
|
72
72
|
|
73
73
|
cache_ids.each do |cache_id|
|
74
74
|
cache_id_value = instance_variable_get('@' + cache_id.to_s)
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/cacheable'
|
7
|
+
require 'steam/community/game_item'
|
8
|
+
require 'steam/community/web_api'
|
9
|
+
|
10
|
+
# Provides basic functionality to represent an inventory of player in a game
|
11
|
+
module GameInventory
|
12
|
+
|
13
|
+
attr_reader :items, :steam_id64
|
14
|
+
|
15
|
+
@@attribute_schema = {}
|
16
|
+
|
17
|
+
@@item_schema = {}
|
18
|
+
|
19
|
+
@@qualities = {}
|
20
|
+
|
21
|
+
@@schema_language = 'en'
|
22
|
+
|
23
|
+
# Sets the language the schema should be fetched in (default is: +'en'+)
|
24
|
+
def self.schema_language=(language)
|
25
|
+
@@schema_language = language
|
26
|
+
end
|
27
|
+
|
28
|
+
# Creates a new inventory object for the given AppID and SteamID64. This
|
29
|
+
# calls update to fetch the data and create the item instances contained in
|
30
|
+
# this players backpack
|
31
|
+
def initialize(steam_id64, fetch_now = true)
|
32
|
+
@steam_id64 = steam_id64
|
33
|
+
|
34
|
+
super fetch_now
|
35
|
+
end
|
36
|
+
|
37
|
+
# Returns the item at the given position in the inventory. The positions
|
38
|
+
# range from 1 to 100 instead of the usual array indices (0 to 99).
|
39
|
+
def [](index)
|
40
|
+
@items[index - 1]
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns the AppID of the game this inventory class belongs to
|
44
|
+
def app_id
|
45
|
+
self.class.send :class_variable_get, :@@app_id
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the attribute schema
|
49
|
+
#
|
50
|
+
# The schemas are fetched first if not done already
|
51
|
+
def attribute_schema
|
52
|
+
update_schema unless @@attribute_schema.key? app_id
|
53
|
+
|
54
|
+
@@attribute_schema[app_id]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Updates the contents of the inventory using Steam Web API
|
58
|
+
def fetch
|
59
|
+
result = WebApi.json!("IEconItems_#{app_id}", 'GetPlayerItems', 1, { :SteamID => @steam_id64 })
|
60
|
+
item_class = self.class.send :class_variable_get, :@@item_class
|
61
|
+
|
62
|
+
@items = []
|
63
|
+
result[:items].each do |item_data|
|
64
|
+
unless item_data.nil?
|
65
|
+
item = item_class.new(self, item_data)
|
66
|
+
@items[item.backpack_position - 1] = item
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns the item schema
|
72
|
+
#
|
73
|
+
# The schemas are fetched first if not done already
|
74
|
+
def item_schema
|
75
|
+
update_schema unless @@item_schema.key? app_id
|
76
|
+
|
77
|
+
@@item_schema[app_id]
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns the quality schema
|
81
|
+
#
|
82
|
+
# The schemas are fetched first if not done already
|
83
|
+
def qualities
|
84
|
+
update_schema unless @@qualities.key? app_id
|
85
|
+
|
86
|
+
@@qualities[app_id]
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns the number of items in the user's inventory
|
90
|
+
def size
|
91
|
+
@items.size
|
92
|
+
end
|
93
|
+
|
94
|
+
protected
|
95
|
+
|
96
|
+
# Updates the item schema (this includes attributes and qualities) using the
|
97
|
+
# +GetSchema+ method of interface +IEconItems_{AppID}+
|
98
|
+
def update_schema
|
99
|
+
params = {}
|
100
|
+
params[:language] = @@schema_language unless @@schema_language.nil?
|
101
|
+
result = WebApi.json!("IEconItems_#{app_id}", 'GetSchema', 1, params)
|
102
|
+
|
103
|
+
@@attribute_schema[app_id] = {}
|
104
|
+
result[:attributes].each do |attribute_data|
|
105
|
+
@@attribute_schema[app_id][attribute_data[:name]] = attribute_data
|
106
|
+
end
|
107
|
+
|
108
|
+
@@item_schema[app_id] = []
|
109
|
+
result[:items].each do |item_data|
|
110
|
+
@@item_schema[app_id][item_data[:defindex]] = item_data
|
111
|
+
end
|
112
|
+
|
113
|
+
@@qualities[app_id] = []
|
114
|
+
result[:qualities].each do |quality, id|
|
115
|
+
@@qualities[app_id][id] = quality
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
|
+
#
|
4
|
+
# Copyright (c) 2011, Sebastian Staudt
|
5
|
+
|
6
|
+
require 'steam/community/web_api'
|
7
|
+
|
8
|
+
# Provides basic functionality to represent an item in a game
|
9
|
+
module GameItem
|
10
|
+
|
11
|
+
attr_reader :attributes, :backpack_position, :class, :count, :defindex, :id,
|
12
|
+
:level, :name, :quality, :slot, :type
|
13
|
+
|
14
|
+
# Creates a new instance of a GameItem with the given data
|
15
|
+
def initialize(inventory, item_data)
|
16
|
+
@defindex = item_data[:defindex]
|
17
|
+
@backpack_position = item_data[:inventory] & 0xffff
|
18
|
+
@class = inventory.item_schema[@defindex][:item_class]
|
19
|
+
@count = item_data[:quantity]
|
20
|
+
@id = item_data[:id]
|
21
|
+
@level = item_data[:level]
|
22
|
+
@name = inventory.item_schema[@defindex][:item_name]
|
23
|
+
@quality = inventory.qualities[item_data[:quality]]
|
24
|
+
@slot = inventory.item_schema[@defindex][:item_slot]
|
25
|
+
@tradeable = !(item_data[:flag_cannot_trade] == true)
|
26
|
+
@type = inventory.item_schema[@defindex][:item_type_name]
|
27
|
+
|
28
|
+
unless inventory.item_schema[@defindex][:attributes].nil?
|
29
|
+
@attributes = inventory.item_schema[@defindex][:attributes]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns whether this item is tradeable
|
34
|
+
def tradeable?
|
35
|
+
@tradeable
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
# This code is free software; you can redistribute it and/or modify it under
|
2
|
-
# terms of the new BSD License.
|
1
|
+
# This code is free software; you can redistribute it and/or modify it under
|
2
|
+
# the terms of the new BSD License.
|
3
3
|
#
|
4
|
-
# Copyright (c) 2008-
|
4
|
+
# Copyright (c) 2008-2011, Sebastian Staudt
|
5
5
|
|
6
6
|
require 'open-uri'
|
7
7
|
require 'rexml/document'
|
@@ -37,6 +37,9 @@ class GameStats
|
|
37
37
|
when 'l4d2'
|
38
38
|
require 'steam/community/l4d/l4d2_stats'
|
39
39
|
L4D2Stats.new(steam_id)
|
40
|
+
when 'portal2'
|
41
|
+
require 'steam/community/portal2/portal2_stats'
|
42
|
+
Portal2Stats.new steam_id
|
40
43
|
when 'tf2'
|
41
44
|
require 'steam/community/tf2/tf2_stats'
|
42
45
|
TF2Stats.new(steam_id)
|
@@ -58,9 +61,12 @@ class GameStats
|
|
58
61
|
url = base_url + '?xml=all'
|
59
62
|
@xml_data = REXML::Document.new(open(url, {:proxy => true}).read).root
|
60
63
|
|
64
|
+
error = @xml_data.elements['error']
|
65
|
+
raise SteamCondenserException.new(error.text) unless error.nil?
|
66
|
+
|
61
67
|
@privacy_state = @xml_data.elements['privacyState'].text
|
62
68
|
if public?
|
63
|
-
@app_id = @xml_data.elements['game/gameLink'].text.match(/http:\/\/store.steampowered.com\/app\/([1-9][0-9]+)/)[1]
|
69
|
+
@app_id = @xml_data.elements['game/gameLink'].text.match(/http:\/\/store.steampowered.com\/app\/([1-9][0-9]+)/)[1].to_i
|
64
70
|
@custom_url = @xml_data.elements['player/customURL'].text if @custom_url.nil?
|
65
71
|
@game_name = @xml_data.elements['game/gameName'].text
|
66
72
|
@hours_played = @xml_data.elements['stats/hoursPlayed'].text unless @xml_data.elements['stats/hoursPlayed'].nil?
|