steam-trade 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +19 -7
- data/lib/Badge.rb +6 -4
- data/lib/Inventory.rb +24 -3
- data/lib/Trade.rb +2 -1
- data/lib/meta/version.rb +1 -1
- data/lib/steam-trade.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3fc04af4fa480c6601e1ad77a07bb1ebe38e2e4
|
4
|
+
data.tar.gz: 585fe12ba2c90ada810fa93b9b90332954729ec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70758d559cb0c022e901b446b1e15d26b9b05edfda7779c5e5d350b8813f544b2beed94f1a136fa7c1653f7fdfd9468a8c32cf3a3cc5af158b1a3e2026a4b87c
|
7
|
+
data.tar.gz: a8a800336a007f320b97c27530563c921b144e41907ea4886577aeef3bd2a7cef761d39cc66d20b4d87b1760210aaf42451798f450f0f21001a3d043c48558c3
|
data/README.md
CHANGED
@@ -1,15 +1,24 @@
|
|
1
|
-
# steam-trade V0.1.
|
1
|
+
# steam-trade V0.1.3
|
2
2
|
Please check constantly for updates cause i'm still making this gem.
|
3
3
|
|
4
4
|
This gem simplifes/allows sending steam trade offers programmatically.
|
5
5
|
|
6
6
|
this gem is primarly for trading cards, tho can be used to CS:GO and other games inventories
|
7
|
+
|
8
|
+
# Changelog
|
9
|
+
```
|
10
|
+
0.1.2:
|
11
|
+
- normal_get_inventory() and raw_get_inventory() now uses Mechanize instead of open-uri.
|
12
|
+
- Handler.new() and fa() now accepts a time difference parameter to adjust your 2FA codes.
|
13
|
+
- sets_count() now writes the txt file faster.
|
14
|
+
- Mechanize session associated with the account now has a 2 second cooldown before each request to avoid spamming steam servers and resulting in a ban.
|
15
|
+
```
|
7
16
|
# Table of content
|
8
17
|
|
9
18
|
- [Installation](#installation)
|
10
19
|
- [Usage & Examples](#usage)
|
11
20
|
- [Logging-in](#logging-in)
|
12
|
-
- [Hander.new() (this is how you login)](#handlernewusername-
|
21
|
+
- [Hander.new() (this is how you login)](#handlernewusername-passwordshared_secrettime_difference)
|
13
22
|
- [mobile_info()](#mobile_infoidentity_secret)
|
14
23
|
- [Getting someone's inventory](#getting-someones-inventory)
|
15
24
|
- [normal_get_inventory()](#normal_get_inventorysteamidinventoryappid)
|
@@ -27,7 +36,7 @@ this gem is primarly for trading cards, tho can be used to CS:GO and other games
|
|
27
36
|
- [Counting badges owned](#counting-badges-owned)
|
28
37
|
- [sets_count()](#sets_counttargetnon_marketable)
|
29
38
|
- [2FA codes](#2fa-codes)
|
30
|
-
- [fa()](#fashared_secret)
|
39
|
+
- [fa()](#fashared_secret-time_difference)
|
31
40
|
- [More commands](#more-commands)
|
32
41
|
|
33
42
|
## Installation
|
@@ -41,14 +50,17 @@ First you need to require the gem:
|
|
41
50
|
require 'steam-trade'
|
42
51
|
```
|
43
52
|
## Logging-in
|
44
|
-
#### `Handler.new(username, password,shared_secret)`
|
53
|
+
#### `Handler.new(username, password,shared_secret,time_difference)`
|
45
54
|
then you need to login and optionally set your shared_secret and identity_secret:
|
46
55
|
- `shared_secret` is used to generate steam authentication codes so you won't have to write them manually each time you login.
|
56
|
+
- `time_difference`is the difference between your time and steam servers, this affects how 2FA codes are generated (**this MUST BE an integer**)
|
47
57
|
```ruby
|
48
58
|
require 'steam-trade'
|
49
59
|
|
50
60
|
account = Handler.new('username','password','shared_secret') # share secret is optional
|
51
|
-
|
61
|
+
account = Handler.new('username','password',50)
|
62
|
+
account = Handler.new('username','password','shared_secret',50)
|
63
|
+
account = Handler.new('username','password',50,'shared_secret') # this will not work
|
52
64
|
##########
|
53
65
|
account = Handler.new('username') #this of course counts as non logged in
|
54
66
|
|
@@ -355,9 +367,9 @@ hash = account.sets_count('https://steamcommunity.com/tradeoffer/new/?partner=41
|
|
355
367
|
|
356
368
|
```
|
357
369
|
## 2FA codes
|
358
|
-
#### `fa(shared_secret)`
|
370
|
+
#### `fa(shared_secret, time_difference)`
|
359
371
|
- `shared_secret` is the account's shared secret (if you don't know what is this try googling 'steam shared_secret'), defaults to the logged in account's steamid if logged in.
|
360
|
-
|
372
|
+
- `time_difference` is the difference between your pc's time and steam's time (**this MUST BE an integer**)
|
361
373
|
**NOTE**: using this command with a new shared_secret will not change/set the current saved shared_secret for the account
|
362
374
|
```ruby
|
363
375
|
require 'steam-trade'
|
data/lib/Badge.rb
CHANGED
@@ -71,9 +71,11 @@ module BadgeCommands
|
|
71
71
|
counted = {}
|
72
72
|
|
73
73
|
sorted.each { |appid,cards|
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
begin
|
75
|
+
counted[appid.to_s] = bigdata[appid].merge(cards)
|
76
|
+
rescue
|
77
|
+
output "badges blueprint does not include #{appid}"
|
78
|
+
end
|
77
79
|
}
|
78
80
|
|
79
81
|
setsowned = {}
|
@@ -86,7 +88,7 @@ module BadgeCommands
|
|
86
88
|
if amount < lowest then lowest = amount end
|
87
89
|
total_non_foil = total_non_foil + amount
|
88
90
|
}
|
89
|
-
setsowned[appid] = lowest
|
91
|
+
setsowned[appid.to_s] = lowest
|
90
92
|
numberofsets = numberofsets + lowest
|
91
93
|
}
|
92
94
|
|
data/lib/Inventory.rb
CHANGED
@@ -174,10 +174,20 @@ module InventoryCommands
|
|
174
174
|
|
175
175
|
private
|
176
176
|
def get_inventory_chunk_normal_way(appid,context,steamid,last_id)
|
177
|
+
html = ''
|
178
|
+
tries = 1
|
179
|
+
|
180
|
+
until html != ''
|
181
|
+
begin
|
182
|
+
html = @session.get("https://steamcommunity.com/inventory/#{steamid}/#{appid}/#{context}?start_assetid=#{last_id}&count=5000").content
|
183
|
+
rescue
|
184
|
+
raise "Cannot get inventory, tried 3 times" if tries == 3
|
185
|
+
tries = tries + 1
|
186
|
+
sleep(0.5)
|
187
|
+
end
|
188
|
+
end
|
177
189
|
|
178
190
|
|
179
|
-
html = @session.get("https://steamcommunity.com/inventory/#{steamid}/#{appid}/#{context}?start_assetid=#{last_id}&count=5000").content
|
180
|
-
|
181
191
|
get = JSON.parse(html)
|
182
192
|
raise "something totally unexpected happened while getting inventory with appid #{appid} of steamid #{steamid} with contextid #{context}" if get.key?("error") == true
|
183
193
|
if get["total_inventory_count"] == 0
|
@@ -222,7 +232,18 @@ module InventoryCommands
|
|
222
232
|
def get_inventory_chunk_raw_way(appid,context,steamid,last_id,trim)
|
223
233
|
|
224
234
|
|
225
|
-
html =
|
235
|
+
html = ''
|
236
|
+
tries = 1
|
237
|
+
|
238
|
+
until html != ''
|
239
|
+
begin
|
240
|
+
html = @session.get("https://steamcommunity.com/inventory/#{steamid}/#{appid}/#{context}?start_assetid=#{last_id}&count=5000").content
|
241
|
+
rescue
|
242
|
+
raise "Cannot get inventory, tried 3 times" if tries == 3
|
243
|
+
tries = tries + 1
|
244
|
+
sleep(0.5)
|
245
|
+
end
|
246
|
+
end
|
226
247
|
|
227
248
|
get = JSON.parse(html)
|
228
249
|
raise "something totally unexpected happened while getting inventory with appid #{appid} of steamid #{steamid} with contextid #{context}" if get.key?("error") == true
|
data/lib/Trade.rb
CHANGED
@@ -62,10 +62,11 @@ module TradeCommands
|
|
62
62
|
output "trade offer sent ID:: " + response["tradeofferid"] + " to #{persona}"
|
63
63
|
if response["needs_mobile_confirmation"] == true
|
64
64
|
if @identity_secret != nil && @steamid != nil
|
65
|
+
sleep(0.6)
|
65
66
|
responsehash = response.merge(send_trade_allow_request(response["tradeofferid"]))
|
66
67
|
output "offer confirmed " + response["tradeofferid"]
|
67
68
|
else
|
68
|
-
output "cannot confirm trade automatically,
|
69
|
+
output "cannot confirm trade automatically, no shared secret given"
|
69
70
|
output "Manual confirmation is needed"
|
70
71
|
end
|
71
72
|
end
|
data/lib/meta/version.rb
CHANGED
data/lib/steam-trade.rb
CHANGED
@@ -57,7 +57,7 @@ class Handler
|
|
57
57
|
@session = Mechanize.new { |agent| # the session which will hold your cookies to communicate with steam
|
58
58
|
agent.user_agent_alias = 'Windows Mozilla'
|
59
59
|
agent.follow_meta_refresh = true
|
60
|
-
agent.history_added = Proc.new {sleep
|
60
|
+
agent.history_added = Proc.new {sleep 1}
|
61
61
|
}
|
62
62
|
|
63
63
|
@inventory_cache = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steam-trade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OmG3r
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|