steam-trade 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6fbde2803532a7f2bd6bf50986fcd678230e07db
4
- data.tar.gz: 9ce311c6a2568ea06ca4068046f2958177e135ce
3
+ metadata.gz: 0a1495678776d1c4806ab7fd802ca00ef28c623c
4
+ data.tar.gz: 21068e4e00aeff3f4c15d98070244f1269dfb35e
5
5
  SHA512:
6
- metadata.gz: 3dc473b18d24ee21829ea9b61504f80faf03cdf377f0fe7789f350d0ab432354a888ba664a89d8945d4ac3045f6be26f556240744a1f576bfbbcbb03aa72e618
7
- data.tar.gz: 6de09926ac61687084e583b9adcba6c382400af597001a11ecefe92e4114d999a1ed3a620eeb5a70bffe5ec036270118bcc6c42ddbafe9711a2f35ea11ad57e8
6
+ metadata.gz: b0f884d6c889ff64fbd0541344c50d25af24f16a7c6fee6d9db418baa9dc56ac98af8409f3d14d9ca398060ae367ed99cd1eb277a5cfac4e0e52998efecb6e80
7
+ data.tar.gz: 545a7d3266806beeff7dadf1a6edd73a4f606e78d6586f5f4ce954e2c274848bb3a731a3c66674086f59728cd981232aafbb52a47f96bdbdcc890c06aa49a537
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # steam-trade V0.1.4
1
+ # steam-trade V0.1.9
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,11 +7,20 @@ 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.7:
11
+ - hotfix
12
+
13
+ 0.1.6:
14
+ - hotfix
15
+
16
+ 0.1.5:
17
+ - added mobile_login() which allows you to send and receive steam messages
18
+ - added oauth_login() uses oauth token and steamMachine cookie to login in ( you get those from mobile_login())
19
+
10
20
  0.1.4:
11
21
  - added Social commands : send friend request, accept friend request, remove friend, send message, get messages
12
22
  - added function to update badges blueprint (useful when there is no gem update)
13
23
 
14
-
15
24
  0.1.3:
16
25
  - decreased cooldown between requests from 2 seconds to 1 second.
17
26
  - added a 0.6 second wait before attempting to confirm a trade offer (mobile).
@@ -50,11 +59,13 @@ this gem is primarly for trading cards, tho can be used to CS:GO and other games
50
59
  - [2FA codes](#2fa-codes)
51
60
  - [fa()](#fashared_secret-time_difference)
52
61
  - [Social Features](#social-commands)
62
+ - [mobile_login()](#mobile_loginusernamepasswordshared_secret)
63
+ - [oauth_login()](#oauth_loginoauth_tokensteammachine)
64
+ - [send_message()](#send_messagetarget-message)
65
+ - [poll_messages()](#poll_messages)
53
66
  - [send_friend_request()](#send_friend_requesttarget)
54
67
  - [accept_friend_request()](#accept_friend_requesttarget)
55
68
  - [remove_friend()](#remove_friendtarget)
56
- - [send_message()](#send_messagetarget-message)
57
- - [poll_messages()](#poll_messages)
58
69
  - [More commands](#more-commands)
59
70
 
60
71
  ## Installation
@@ -385,7 +396,7 @@ hash = account.sets_count('https://steamcommunity.com/tradeoffer/new/?partner=41
385
396
 
386
397
  ```
387
398
 
388
- #### update_blueprint()
399
+ #### `update_blueprint()`
389
400
  - updates your locally saved badges blueprint
390
401
  ```ruby
391
402
  require 'steam-trade'
@@ -417,63 +428,95 @@ puts logged.fa() # will give a random code
417
428
 
418
429
  ```
419
430
  ## 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
431
+ #### `mobile_login('username','password','shared_secret')`
432
+ - this command will be called automatically if you attempt to use `send_message()` or `poll_messages()` without authentication
433
+ - calling this explicitly allows you to painlessly retrieve the OAuth token and `SteamMachine#{steamid}` cookie to use in `oauth_login()`
434
+ - this function returns a hash with `oauth_token` and `machine` as keys
435
+ ```ruby
436
+ require 'steam-trade'
437
+
438
+ h = Handler.new('user','pass','secret')
439
+ data = h.mobile_login() #this works are you have setted username and password
440
+ puts data ## will output with oauth token and steamMachine cookie
441
+
442
+ ###################
443
+ h = Handler.new()
444
+ data = h.mobile_login() # will raise an error cause there is no username or password
424
445
 
446
+ ##########
447
+
448
+ h = Handler.new()
449
+ data = h.mobile_login('user','pass','secret') ## will work, you are not logged in ( talking about community) here you can't use most of the commands (send_offer() etc) and those parameters you passed will not be setted as the Handler's
450
+
451
+ ######
452
+ h = Handler.new('user1','pass1','secret1')
453
+ data = mobile_login('user2','pass2','secret2') # this works but trading commands etc will be called using user1, and chat commands will be called using user2
454
+ ```
455
+ #### `oauth_login(oauth_token,SteamMachine)`
456
+ - `oauth_token` and `SteamMachine` can be retrieved from `mobile_login()`
457
+ ```ruby
458
+ require 'steam-trade'
459
+ h = Handler.new()
460
+ h.oauth_login('oauth_token','SteamMachine')
461
+ ```
462
+ #### `send_message(target, message)`
463
+ sends a message to the target
464
+ - `target` can be a steamID64, tradelink, or profileID
465
+ - `message` the message to send
425
466
  ```ruby
426
467
  require 'steam-trade'
427
468
 
428
469
  h = Handler.new('username', 'password')
429
- h.send_friend_request('nomg3r')
470
+ h.send_message('nomg3r', "Hello, Friend")
430
471
  ```
431
472
 
432
- ### `accept_friend_request(target)`
433
- accepts a friend request from the target
434
- - `target` can be a steamID64, tradelink, or profileID
473
+ #### `poll_messages()`
474
+ gives you the messages you receieved (after mobile login is initiated (after you call send_message() or poll_messages() ) )
435
475
 
436
476
  ```ruby
437
477
  require 'steam-trade'
438
478
 
439
479
  h = Handler.new('username', 'password')
440
- h.accept_friend_request('nomg3r')
480
+ print h.poll_messages() # will not return messages so you call at again ( only the first time in the whole program )
481
+ puts ""
482
+ puts "------"
483
+ sleep(10) #send a message to the logged in account
484
+ print h.poll_messages() # actually have messages ( if you received some in the time between the first and the second request )
441
485
  ```
442
-
443
- ### `remove_friend(target)`
444
- removes a friend
486
+ **ALL OF THE COMMANDS BELOW REQUIRES LOGIN**
487
+ #### `send_friend_request(target)`
488
+ sends a friend request to the target
445
489
  - `target` can be a steamID64, tradelink, or profileID
446
490
 
447
491
  ```ruby
448
492
  require 'steam-trade'
449
493
 
450
494
  h = Handler.new('username', 'password')
451
- h.remove_friend('nomg3r')
495
+ h.send_friend_request('nomg3r')
452
496
  ```
453
- ### `send_message(target, message)`
454
- sends a message to the target
497
+
498
+ #### `accept_friend_request(target)`
499
+ accepts a friend request from the target
455
500
  - `target` can be a steamID64, tradelink, or profileID
456
- - `message` the message to send
501
+
457
502
  ```ruby
458
503
  require 'steam-trade'
459
504
 
460
505
  h = Handler.new('username', 'password')
461
- h.send_message('nomg3r', "Hello, Friend)
506
+ h.accept_friend_request('nomg3r')
462
507
  ```
463
508
 
464
- ### `poll_messages()`
465
- gives you the messages you receieved (after mobile login is initiated (after you call send_message() or poll_messages() ) )
509
+ ### `remove_friend(target)`
510
+ removes a friend
511
+ - `target` can be a steamID64, tradelink, or profileID
466
512
 
467
513
  ```ruby
468
514
  require 'steam-trade'
469
515
 
470
516
  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 )
517
+ h.remove_friend('nomg3r')
476
518
  ```
519
+
477
520
  ## More commands
478
521
  you can find more non-vital commands in the [wiki](https://github.com/OmG3r/steam-trade/wiki)
479
522
  ## License
data/lib/LoginExecutor.rb CHANGED
@@ -3,7 +3,7 @@ module LoginCommands
3
3
  ########################################################################################
4
4
  private
5
5
  def login()
6
- response = @session.post('https://store.steampowered.com/login/getrsakey/', {'username' => @username})
6
+ response = @session.post('https://store.steampowered.com/login/getrsakey/', {'username' => @username}).content
7
7
  data = pass_stamp(response,@password)
8
8
  encrypted_password = data["password"]
9
9
  timestamp = data["timestamp"]
@@ -27,7 +27,7 @@ module LoginCommands
27
27
  'captcha_text' => '',
28
28
  'emailsteamid' => '',
29
29
  'rsatimestamp' => timestamp,
30
- 'remember_login' => 'false'
30
+ 'remember_login' => @remember
31
31
  }
32
32
 
33
33
  login = @session.post('https://store.steampowered.com/login/dologin', send )
data/lib/meta/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Meta
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.9"
3
3
  GEM_NAME = "steam-trade"
4
4
  end
data/lib/steam-trade.rb CHANGED
@@ -31,13 +31,15 @@ class Handler
31
31
  include SocialCommands
32
32
 
33
33
  def initialize(username = nil ,password = nil,*params)
34
- raise "can only take 4 params, given #{params.length}" if params.length > 2
34
+ raise "can only take 5 params, given #{params.length}" if params.length > 3
35
+
35
36
  @loggedin = false # will be set to true once we login
36
37
 
37
- @username = username
38
- @password = password
38
+ @username = nil
39
+ @password = nil
39
40
  @secret = nil
40
41
  @time_difference = 0
42
+ @remember = false
41
43
 
42
44
  @session = Mechanize.new { |a| # the session which will hold your cookies to communicate with steam
43
45
  a.user_agent_alias = 'Windows Mozilla'
@@ -46,17 +48,6 @@ class Handler
46
48
  # a.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE
47
49
  }
48
50
 
49
- if params.length == 2
50
- @secret = params[0] if params[0].class == String
51
- @time_difference = params[1] if params[1].class == Integer
52
- elsif params.length == 1 && params[0].class == String
53
- @secret = params[0]
54
- @time_difference = 0
55
- elsif params.length == 1 && params[0].class == Integer
56
- @secret = nil
57
- @time_difference = params[0]
58
- end
59
-
60
51
  @steamid = nil # will be initialized once you login and can be initialized with mobile_info
61
52
  @identity_secret = nil # can and should be initialized using mobile_info
62
53
  @api_key = nil # can be initalized through set_api_key or will be initialized once you login if possilbe
@@ -73,30 +64,67 @@ class Handler
73
64
  @umqid = nil # required to send messages
74
65
  @message_id = nil #requires to send messages
75
66
 
76
- if @username.nil?
77
- output "Handler started"
78
- else
79
- output "Handler started for #{@username}"
80
- end
81
- if username != nil && password != nil
67
+
68
+
69
+
70
+ if params.length == 3
71
+ raise "shared_secret must be string, received #{parasm[0].class}" if params[0].class != String
72
+ raise "time difference must be an integer, received #{params[1].class}" if params[1].class != Integer
73
+ raise "remember_me must be a boolean, received #{params[2].class}" if !([TrueClass,FalseClass].include?(params[2].class))
74
+ @secret = params[0] if params[0].class == String
75
+ @time_difference = params[1] if params[1].class == Integer
76
+ @remember = params[2] if [TrueClass,FalseClass].include?(params[2].class)
77
+ elsif params.length == 2
78
+ if params[0].class == String
79
+ raise "invalid fourth parameter type, received #{params[1].class}" if !([TrueClass,FalseClass].include?(params[1].class)) && params[1].class != Integer
80
+ @secret = params[0]
81
+ @time_difference = params[1] if params[1].class == Integer
82
+ @remember = params[1] if [TrueClass,FalseClass].include?(params[1].class)
83
+ elsif params[0].class == Integer
84
+ raise "remember_me must be a boolean, received #{params[1].class}" if !([TrueClass,FalseClass].include?(params[1].class))
85
+ @time_difference = params[0]
86
+ @remember = params[1]
87
+ else
88
+ raise "invalid third parameter type"
89
+ end
90
+ elsif params.length == 1
91
+ raise "invalid third parameter type, received #{params[0].class}" if !([TrueClass,FalseClass].include?(params[0].class)) && params[0].class != Integer && params[0].class != String
92
+ @secret = params[0] if params[0].class == String
93
+ @time_difference = params[0] if params[0].class == Integer
94
+ @remember = params[0] if [TrueClass,FalseClass].include?(params[0].class)
95
+ end
96
+
97
+
98
+
99
+
100
+ (@username.nil? || @username.class == Hash) ? (output "Handler started") : ( output "Handler started for #{@username}")
101
+
102
+ if username.class == String && password.class == String
103
+ @username = username
104
+ @password = password
82
105
  login()
83
- end
106
+ elsif username.class == Hash
107
+ load_cookies(username)
108
+ end
109
+
110
+
84
111
  end
85
112
 
113
+
86
114
  def mobile_info(identity_secret, steamid = nil)
87
115
  @identity_secret = identity_secret
88
- if @steamid == nil && steamid != nil
89
- @steamid = steamid
90
- end
116
+ @steamid = steamid if @steamid == nil && steamid != nil
91
117
  end
92
118
 
93
119
  def set_inventory_cache(timer = 120)
94
120
  integer = 5
95
121
  float = 5.5
96
122
  if timer.class == integer.class || timer.class == float.class
97
- @inventory_validity = timer
123
+ @inventory_validity = timer.to_i
98
124
  output "inventory validity set to #{timer}"
99
125
  end
126
+
127
+
100
128
  if @inventory_cache == false
101
129
  @inventory_cache = true
102
130
  output "inventory cache enabled"
@@ -111,13 +139,75 @@ class Handler
111
139
  end
112
140
 
113
141
  def toggle_messages()
114
- if @messages == true
115
- output "messages are now disabled"
116
- @messages = false
117
- else
118
- @messages = true
119
- output "messages are now enabled"
120
- end
142
+ @messages == true ? (output "messages are now disabled"; @messages = false;) : (output "messages are now enabled";@messages = true;)
143
+ end
144
+
145
+
146
+
147
+
148
+ def get_auth_cookies()
149
+ data = {}
150
+ #data['sessionid'] = @session.cookie_jar.jar["steamcommunity.com"]["/"]["sessionid"].value
151
+ begin
152
+ data['steamLogin'] = @session.cookie_jar.jar["store.steampowered.com"]["/"]["steamLogin"].value
153
+ rescue
154
+ data['steamLogin'] = @session.cookie_jar.jar["steamcommunity.com"]["/"]["steamLogin"].value
155
+ end
156
+
157
+ begin
158
+ data['steamLoginSecure'] = @session.cookie_jar.jar["store.steampowered.com"]["/"]["steamLoginSecure"].value
159
+ rescue
160
+ data['steamLoginSecure'] = @session.cookie_jar.jar["steamcommunity.com"]["/"]["steamLoginSecure"].value
161
+ end
162
+
163
+ if @steamid != nil
164
+ begin
165
+ data["steamMachineAuth#{@steamid}"] = @session.cookie_jar.jar["store.steampowered.com"]["/"]["steamMachineAuth#{@steamid}"].value
166
+ rescue
167
+ data["steamMachineAuth#{@steamid}"] = @session.cookie_jar.jar["steamcommunity.com"]["/"]["steamMachineAuth#{@steamid}"].value
168
+ end
169
+
170
+ else
171
+
172
+ @session.cookies.each { |c|
173
+ if c.downcase.include?('steammachine')
174
+ data[c] = c.value
175
+ end
176
+ }
177
+ end
178
+
179
+ return data
180
+
181
+
121
182
  end
183
+ private
184
+ def load_cookies(data)
185
+ container = []
186
+ data.each { |name, value|
187
+ if name.include?("steamMachineAuth")
188
+ container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name => name , :value => value, :path => '/')
189
+ container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name => name , :value =>value, :path => '/')
190
+ container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name => name , :value => value, :path => '/')
191
+ @steamid = name.sub('steamMachineAuth', '')
192
+ elsif name == 'steamLogin'
193
+ container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name => name , :value => value, :path => '/')
194
+ container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name => name , :value =>value, :path => '/')
195
+ container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name => name , :value => value, :path => '/')
196
+ elsif name == 'steamLoginSecure'
197
+ container << (Mechanize::Cookie.new :domain => 'store.steampowered.com', :name => name , :value => value, :path => '/')
198
+ container << (Mechanize::Cookie.new :domain => 'steamcommunity.com', :name => name , :value =>value, :path => '/')
199
+ container << (Mechanize::Cookie.new :domain => 'help.steampowered.com', :name => name , :value => value, :path => '/')
200
+ end
201
+ }
202
+
203
+ container.each { |cookie|
204
+ @session.cookie_jar << cookie
205
+ }
206
+ user = Nokogiri::HTML(@session.get('https://store.steampowered.com/stats/').content).css('#account_pulldown').text
207
+ raise "Could not login using cookies" if user == ''
208
+ output "logged in as #{user}"
209
+ end
210
+
211
+
122
212
 
123
213
  end
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.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - OmG3r
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-20 00:00:00.000000000 Z
11
+ date: 2018-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler