steam-trade 0.1.4 → 0.1.7
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 +81 -1
- data/lib/LoginExecutor.rb +3 -3
- data/lib/Misc.rb +4 -2
- data/lib/Social.rb +91 -31
- data/lib/blueprints/byappid.json +1 -1
- data/lib/meta/version.rb +1 -1
- data/lib/steam-trade.rb +6 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6fbde2803532a7f2bd6bf50986fcd678230e07db
|
|
4
|
+
data.tar.gz: 9ce311c6a2568ea06ca4068046f2958177e135ce
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dc473b18d24ee21829ea9b61504f80faf03cdf377f0fe7789f350d0ab432354a888ba664a89d8945d4ac3045f6be26f556240744a1f576bfbbcbb03aa72e618
|
|
7
|
+
data.tar.gz: 6de09926ac61687084e583b9adcba6c382400af597001a11ecefe92e4114d999a1ed3a620eeb5a70bffe5ec036270118bcc6c42ddbafe9711a2f35ea11ad57e8
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# steam-trade V0.1.
|
|
1
|
+
# steam-trade V0.1.4
|
|
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.
|
|
@@ -7,6 +7,11 @@ this gem is primarly for trading cards, tho can be used to CS:GO and other games
|
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
```
|
|
10
|
+
0.1.4:
|
|
11
|
+
- added Social commands : send friend request, accept friend request, remove friend, send message, get messages
|
|
12
|
+
- added function to update badges blueprint (useful when there is no gem update)
|
|
13
|
+
|
|
14
|
+
|
|
10
15
|
0.1.3:
|
|
11
16
|
- decreased cooldown between requests from 2 seconds to 1 second.
|
|
12
17
|
- added a 0.6 second wait before attempting to confirm a trade offer (mobile).
|
|
@@ -41,8 +46,15 @@ this gem is primarly for trading cards, tho can be used to CS:GO and other games
|
|
|
41
46
|
- [cancel_trade_offer()](#cancel_trade_offertrade_offer_id)
|
|
42
47
|
- [Counting badges owned](#counting-badges-owned)
|
|
43
48
|
- [sets_count()](#sets_counttargetnon_marketable)
|
|
49
|
+
- [update_blueprint()](#update_blueprint)
|
|
44
50
|
- [2FA codes](#2fa-codes)
|
|
45
51
|
- [fa()](#fashared_secret-time_difference)
|
|
52
|
+
- [Social Features](#social-commands)
|
|
53
|
+
- [send_friend_request()](#send_friend_requesttarget)
|
|
54
|
+
- [accept_friend_request()](#accept_friend_requesttarget)
|
|
55
|
+
- [remove_friend()](#remove_friendtarget)
|
|
56
|
+
- [send_message()](#send_messagetarget-message)
|
|
57
|
+
- [poll_messages()](#poll_messages)
|
|
46
58
|
- [More commands](#more-commands)
|
|
47
59
|
|
|
48
60
|
## Installation
|
|
@@ -371,6 +383,16 @@ hash = account.sets_count('CardExchange')
|
|
|
371
383
|
hash = account.sets_count(76561198370420964)
|
|
372
384
|
hash = account.sets_count('https://steamcommunity.com/tradeoffer/new/?partner=410155236&token=H-yK-GFt',false)
|
|
373
385
|
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
#### update_blueprint()
|
|
389
|
+
- updates your locally saved badges blueprint
|
|
390
|
+
```ruby
|
|
391
|
+
require 'steam-trade'
|
|
392
|
+
|
|
393
|
+
handler = Handler.new
|
|
394
|
+
|
|
395
|
+
handler.update_blueprint()
|
|
374
396
|
```
|
|
375
397
|
## 2FA codes
|
|
376
398
|
#### `fa(shared_secret, time_difference)`
|
|
@@ -393,6 +415,64 @@ nonlogged = Handler.new()
|
|
|
393
415
|
puts nonlogged.fa() # will not work
|
|
394
416
|
puts logged.fa() # will give a random code
|
|
395
417
|
|
|
418
|
+
```
|
|
419
|
+
## Social Commands
|
|
420
|
+
**ALL OF THE COMMANDS BELOW REQUIRES LOGIN**
|
|
421
|
+
### `send_friend_request(target)`
|
|
422
|
+
sends a friend request to the target
|
|
423
|
+
- `target` can be a steamID64, tradelink, or profileID
|
|
424
|
+
|
|
425
|
+
```ruby
|
|
426
|
+
require 'steam-trade'
|
|
427
|
+
|
|
428
|
+
h = Handler.new('username', 'password')
|
|
429
|
+
h.send_friend_request('nomg3r')
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### `accept_friend_request(target)`
|
|
433
|
+
accepts a friend request from the target
|
|
434
|
+
- `target` can be a steamID64, tradelink, or profileID
|
|
435
|
+
|
|
436
|
+
```ruby
|
|
437
|
+
require 'steam-trade'
|
|
438
|
+
|
|
439
|
+
h = Handler.new('username', 'password')
|
|
440
|
+
h.accept_friend_request('nomg3r')
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### `remove_friend(target)`
|
|
444
|
+
removes a friend
|
|
445
|
+
- `target` can be a steamID64, tradelink, or profileID
|
|
446
|
+
|
|
447
|
+
```ruby
|
|
448
|
+
require 'steam-trade'
|
|
449
|
+
|
|
450
|
+
h = Handler.new('username', 'password')
|
|
451
|
+
h.remove_friend('nomg3r')
|
|
452
|
+
```
|
|
453
|
+
### `send_message(target, message)`
|
|
454
|
+
sends a message to the target
|
|
455
|
+
- `target` can be a steamID64, tradelink, or profileID
|
|
456
|
+
- `message` the message to send
|
|
457
|
+
```ruby
|
|
458
|
+
require 'steam-trade'
|
|
459
|
+
|
|
460
|
+
h = Handler.new('username', 'password')
|
|
461
|
+
h.send_message('nomg3r', "Hello, Friend)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
### `poll_messages()`
|
|
465
|
+
gives you the messages you receieved (after mobile login is initiated (after you call send_message() or poll_messages() ) )
|
|
466
|
+
|
|
467
|
+
```ruby
|
|
468
|
+
require 'steam-trade'
|
|
469
|
+
|
|
470
|
+
h = Handler.new('username', 'password')
|
|
471
|
+
print h.poll_messages() # will not return messages so you call at again ( only the first time in the whole program )
|
|
472
|
+
puts ""
|
|
473
|
+
puts "------"
|
|
474
|
+
sleep(10) #send a message to the logged in account
|
|
475
|
+
print h.poll_messages() # actually have messages ( if you received some in the time between the first and the second request )
|
|
396
476
|
```
|
|
397
477
|
## More commands
|
|
398
478
|
you can find more non-vital commands in the [wiki](https://github.com/OmG3r/steam-trade/wiki)
|
data/lib/LoginExecutor.rb
CHANGED
|
@@ -4,7 +4,7 @@ module LoginCommands
|
|
|
4
4
|
private
|
|
5
5
|
def login()
|
|
6
6
|
response = @session.post('https://store.steampowered.com/login/getrsakey/', {'username' => @username})
|
|
7
|
-
data = pass_stamp(response)
|
|
7
|
+
data = pass_stamp(response,@password)
|
|
8
8
|
encrypted_password = data["password"]
|
|
9
9
|
timestamp = data["timestamp"]
|
|
10
10
|
repeater = 0
|
|
@@ -89,7 +89,7 @@ module LoginCommands
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
########################################################################################
|
|
92
|
-
def pass_stamp(give)
|
|
92
|
+
def pass_stamp(give,password)
|
|
93
93
|
|
|
94
94
|
data = JSON::parse(give)
|
|
95
95
|
mod = data["publickey_mod"].hex
|
|
@@ -99,7 +99,7 @@ module LoginCommands
|
|
|
99
99
|
key = OpenSSL::PKey::RSA.new
|
|
100
100
|
key.e = OpenSSL::BN.new(exp)
|
|
101
101
|
key.n = OpenSSL::BN.new(mod)
|
|
102
|
-
ep = Base64.encode64(key.public_encrypt(
|
|
102
|
+
ep = Base64.encode64(key.public_encrypt(password.force_encoding("utf-8"))).gsub("\n", '')
|
|
103
103
|
return {'password' => ep, 'timestamp' => timestamp }
|
|
104
104
|
end
|
|
105
105
|
########################################################################################
|
data/lib/Misc.rb
CHANGED
|
@@ -26,7 +26,9 @@ module MiscCommands
|
|
|
26
26
|
end
|
|
27
27
|
########################################################################################
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
def use_chat_session()
|
|
30
|
+
@chat_session
|
|
31
|
+
end
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
|
|
@@ -76,7 +78,7 @@ module MiscCommands
|
|
|
76
78
|
end
|
|
77
79
|
if value == nil
|
|
78
80
|
begin
|
|
79
|
-
@session.cookie_jar.jar["store.steampowered.com"]["/"]["sessionid"].value
|
|
81
|
+
value = @session.cookie_jar.jar["store.steampowered.com"]["/"]["sessionid"].value
|
|
80
82
|
rescue
|
|
81
83
|
value = nil
|
|
82
84
|
end
|
data/lib/Social.rb
CHANGED
|
@@ -42,8 +42,8 @@ module SocialCommands
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def send_message(id, message)
|
|
45
|
-
raise "
|
|
46
|
-
|
|
45
|
+
raise "no account details given cannot poll messages" if @chat_session.nil? && @username.nil?
|
|
46
|
+
mobile_login() if @chat_session.nil?
|
|
47
47
|
|
|
48
48
|
steamid = verify_profileid_or_trade_link_or_steamid(id)
|
|
49
49
|
|
|
@@ -59,8 +59,8 @@ module SocialCommands
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
def poll_messages()
|
|
62
|
-
raise "
|
|
63
|
-
|
|
62
|
+
raise "no account details given cannot poll messages" if @chat_session.nil? && @username.nil?
|
|
63
|
+
mobile_login() if @chat_session.nil?
|
|
64
64
|
response = @chat_session.post('https://api.steampowered.com/ISteamWebUserPresenceOAuth/Poll/v1', {
|
|
65
65
|
"umqid": @umqid,
|
|
66
66
|
"message": @message_id,
|
|
@@ -77,17 +77,18 @@ module SocialCommands
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
|
|
80
|
-
private
|
|
81
|
-
def chat_start()
|
|
82
|
-
mobile_login()
|
|
83
|
-
get_umqid()
|
|
84
|
-
end
|
|
85
80
|
|
|
86
81
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def mobile_login(username = @username, password = @password, secret = nil)
|
|
85
|
+
secret = @secret if username == @username
|
|
86
|
+
raise "username is required to do a chat login" if username.nil?
|
|
87
|
+
raise "password is required to do a chat login" if password.nil?
|
|
88
|
+
|
|
89
|
+
@chat_session = Mechanize.new { |a| # the session which will hold your cookies to communicate with steam
|
|
90
|
+
a.follow_meta_refresh = true
|
|
91
|
+
# a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
mobileheaders = {
|
|
@@ -108,16 +109,16 @@ module SocialCommands
|
|
|
108
109
|
@chat_session.cookie_jar << cookie
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
response = @chat_session.post('https://steamcommunity.com/login/getrsakey/', {'username' =>
|
|
112
|
+
response = @chat_session.post('https://steamcommunity.com/login/getrsakey/', {'username' => username}, mobileheaders).content
|
|
112
113
|
|
|
113
114
|
|
|
114
|
-
data = pass_stamp(response)
|
|
115
|
+
data = pass_stamp(response,password)
|
|
115
116
|
encrypted_password = data["password"]
|
|
116
117
|
timestamp = data["timestamp"]
|
|
117
118
|
repeater = 0
|
|
118
119
|
until repeater == true
|
|
119
|
-
if
|
|
120
|
-
guardcode = fa(
|
|
120
|
+
if secret != nil
|
|
121
|
+
guardcode = fa(secret,0)
|
|
121
122
|
else
|
|
122
123
|
puts "please write your 2FA code (mobile login to send messages)"
|
|
123
124
|
guardcode = gets.chomp
|
|
@@ -130,10 +131,10 @@ module SocialCommands
|
|
|
130
131
|
'emailauth' => '',
|
|
131
132
|
'emailsteamid' => '',
|
|
132
133
|
'password' => encrypted_password,
|
|
133
|
-
'remember_login' => '
|
|
134
|
+
'remember_login' => 'true',
|
|
134
135
|
'rsatimestamp' => timestamp,
|
|
135
136
|
'twofactorcode' =>guardcode,
|
|
136
|
-
'username' =>
|
|
137
|
+
'username' => username,
|
|
137
138
|
'loginfriendlyname' => '#login_emailauth_friendlyname_mobile',
|
|
138
139
|
'oauth_scope' => "read_profile write_profile read_client write_client",
|
|
139
140
|
'oauth_client_id' => "DE45CD61"
|
|
@@ -145,7 +146,7 @@ module SocialCommands
|
|
|
145
146
|
if response["success"] == true
|
|
146
147
|
repeater = true
|
|
147
148
|
elsif repeater == 3
|
|
148
|
-
raise "Login (mobile) failed username: #{
|
|
149
|
+
raise "Login (mobile) failed username: #{username}, password: #{password}, shared_scret: #{secret} tried 3 times"
|
|
149
150
|
else
|
|
150
151
|
|
|
151
152
|
sleep(2)
|
|
@@ -157,11 +158,54 @@ module SocialCommands
|
|
|
157
158
|
|
|
158
159
|
oauth_hash = JSON.parse(response["oauth"]) # steam returns a hash as a string
|
|
159
160
|
@oauth_token = oauth_hash["oauth_token"]
|
|
161
|
+
machinevalue = steammachine_cookie(oauth_hash["steamid"])
|
|
162
|
+
get_umqid()
|
|
163
|
+
return {"oauth_token" => @oauth_token, "machine" => machinevalue}
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def oauth_login(oauth_token,machinevalue)
|
|
169
|
+
|
|
170
|
+
@chat_session = Mechanize.new { |a| # the session which will hold your cookies to communicate with steam
|
|
171
|
+
a.follow_meta_refresh = true
|
|
172
|
+
# a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@oauth_token = oauth_token
|
|
177
|
+
response = @chat_session.post('https://api.steampowered.com/IMobileAuthService/GetWGToken/v1/', {"access_token" => oauth_token}).content
|
|
178
|
+
data = JSON.parse(response)
|
|
179
|
+
data = data["response"]
|
|
180
|
+
|
|
181
|
+
raise "error. cannot login" if data["token"].nil? || data["token_secure"].nil?
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
steamid = get_umqid(true) ##umqid got
|
|
185
|
+
|
|
186
|
+
## loading cookies
|
|
187
|
+
container = []
|
|
188
|
+
container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name =>'steamLogin', :value =>data["token"], :path => '/')
|
|
189
|
+
container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name =>'steamLogin', :value =>data["token"], :path => '/')
|
|
190
|
+
container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name =>'steamLogin', :value =>data["token"], :path => '/')
|
|
191
|
+
|
|
192
|
+
container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name =>'steamLoginSecure', :value =>data["token_secure"], :path => '/')
|
|
193
|
+
container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name =>'steamLoginSecure', :value =>data["token_secure"], :path => '/')
|
|
194
|
+
container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name =>'steamLoginSecure', :value =>data["token_secure"], :path => '/')
|
|
195
|
+
|
|
196
|
+
container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name => "steamMachineAuth#{steamid}" , :value => machinevalue, :path => '/')
|
|
197
|
+
container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name => "steamMachineAuth#{steamid}" , :value => machinevalue, :path => '/')
|
|
198
|
+
container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name => "steamMachineAuth#{steamid}" , :value => machinevalue, :path => '/')
|
|
199
|
+
|
|
200
|
+
container.each { |cookie|
|
|
201
|
+
@chat_session.cookie_jar << cookie
|
|
202
|
+
}
|
|
160
203
|
|
|
161
204
|
|
|
162
205
|
end
|
|
163
206
|
|
|
164
|
-
|
|
207
|
+
private
|
|
208
|
+
def get_umqid(re = false)
|
|
165
209
|
response = @chat_session.post('https://api.steampowered.com/ISteamWebUserPresenceOAuth/Logon/v1', {
|
|
166
210
|
'ui_mode' => 'web',
|
|
167
211
|
'access_token' => @oauth_token
|
|
@@ -170,16 +214,32 @@ module SocialCommands
|
|
|
170
214
|
@umqid = hash["umqid"]
|
|
171
215
|
@message_id = hash["message"]
|
|
172
216
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"message": @message_id,
|
|
177
|
-
"pollid": 1,
|
|
178
|
-
"sectimeout": 20,
|
|
179
|
-
"secidletime": 0,
|
|
180
|
-
"use_accountids": 0,
|
|
181
|
-
"access_token": @oauth_token
|
|
182
|
-
})
|
|
217
|
+
(return hash["steamid"]) if re == true
|
|
218
|
+
end
|
|
219
|
+
|
|
183
220
|
|
|
221
|
+
def steammachine_cookie(steamid)
|
|
222
|
+
value = nil
|
|
223
|
+
begin
|
|
224
|
+
value = @chat_session.cookie_jar.jar["steamcommunity.com"]["/"]["steamMachineAuth#{steamid}"].value
|
|
225
|
+
rescue
|
|
226
|
+
value = nil
|
|
227
|
+
end
|
|
228
|
+
if value == nil
|
|
229
|
+
begin
|
|
230
|
+
value = @chat_session.cookie_jar.jar["store.steampowered.com"]["/"]["steamMachineAuth#{steamid}"].value
|
|
231
|
+
rescue
|
|
232
|
+
value = nil
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
if value == nil
|
|
237
|
+
@chat_session.cookies.each { |c|
|
|
238
|
+
if c.name == "steamMachineAuth#{steamid}"
|
|
239
|
+
value = c.value
|
|
240
|
+
end
|
|
241
|
+
}
|
|
242
|
+
end
|
|
243
|
+
return value
|
|
184
244
|
end
|
|
185
245
|
end
|