steamutils 1.1.45 → 1.1.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +41 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1516,14 +1516,14 @@ class SteamUser {
1516
1516
 
1517
1517
  let now = 0
1518
1518
  let diff = 0
1519
- while ((diff = (now = new Date().getTime()) - requestTimestamp) < 500) {
1520
- await sleep(diff + 10)
1521
- }
1522
1519
  if (checkTooManyRequest) {
1523
1520
  while ((diff = (now = new Date().getTime()) - tooManyRequestTimestamp) < 30000) {
1524
1521
  await sleep(diff + 10)
1525
1522
  }
1526
1523
  }
1524
+ while ((diff = (now = new Date().getTime()) - requestTimestamp) < 500) {
1525
+ await sleep(diff + 10)
1526
+ }
1527
1527
  requestTimestamp = now
1528
1528
  response = await axios.request(config)
1529
1529
 
@@ -5425,6 +5425,44 @@ class SteamUser {
5425
5425
  const trade_offer_access_url = $('#trade_offer_access_url').attr('value')
5426
5426
  return trade_offer_access_url
5427
5427
  }
5428
+
5429
+ async sendTradeOffer({tradeURL, me, them, tradeoffermessage = ''}) {//partner: steamid not accountid
5430
+ // const meExample = {
5431
+ // "assets": [{"appid": 730, "contextid": "2", "amount": 1, "assetid": "30492209501"}],
5432
+ // "currency": [],
5433
+ // "ready": false
5434
+ // }
5435
+ // const themExample = {
5436
+ // "assets": [{"appid": 730, "contextid": "2", "amount": 1, "assetid": "30494845811"}],
5437
+ // "currency": [],
5438
+ // "ready": false
5439
+ // }
5440
+ const tradeURLParams = url.parse(tradeURL).query.split('&').reduce((accumulator, currentValue, index) => ({
5441
+ ...accumulator, [currentValue.split('=')[0]]: currentValue.split('=')[1]
5442
+ }), {})
5443
+ const result = await this._httpRequest({
5444
+ url: `tradeoffer/new/send`,
5445
+ headers: {
5446
+ Referer: tradeURL
5447
+ },
5448
+ data: {
5449
+ serverid: 1,
5450
+ partner: SteamID.fromIndividualAccountID(tradeURLParams.partner).getSteamID64(),
5451
+ tradeoffermessage,
5452
+ json: JSON.stringify({
5453
+ newversion: true,
5454
+ version: 3,
5455
+ me,
5456
+ them,
5457
+ }),
5458
+ captcha: '',
5459
+ trade_offer_create_params: JSON.stringify({trade_offer_access_token: tradeURLParams.token}),
5460
+ account: this.getMiniProfileUser(),
5461
+ },
5462
+ method: 'POST',
5463
+ })
5464
+ return result.data
5465
+ }
5428
5466
  }
5429
5467
 
5430
5468
  export default SteamUser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "main":"index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",