steamutils 1.1.66 → 1.1.67

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.
Files changed (3) hide show
  1. package/example.js +0 -1
  2. package/index.js +65 -1
  3. package/package.json +1 -1
package/example.js CHANGED
@@ -10,5 +10,4 @@ import * as cherrio from "cheerio";
10
10
  // console.log(loginResult.cookie);
11
11
  // const user = new SteamUser(loginResult.cookie)
12
12
 
13
-
14
13
  })()
package/index.js CHANGED
@@ -5489,13 +5489,77 @@ class SteamUser {
5489
5489
  })
5490
5490
  return result.data
5491
5491
  const resultExample = {
5492
- tradeofferid: "6093097382",
5492
+ tradeofferid: "6093091333",
5493
5493
  needs_mobile_confirmation: true,
5494
5494
  needs_email_confirmation: false,
5495
5495
  email_domain: "gmail.com"
5496
5496
  }
5497
5497
  }
5498
5498
 
5499
+ async getTradeOffer() {
5500
+ const result = await this._httpRequest({
5501
+ url: `${this._myProfile}/tradeoffers/`,
5502
+ method: 'GET',
5503
+ })
5504
+ const $ = result._$()
5505
+
5506
+ const IncomingOffers = {}
5507
+ const SentOffers = {}
5508
+ let tradeHodeCount = 0
5509
+ const tradeOffers = []
5510
+
5511
+
5512
+ $('.profile_subpage_selector > a').each(function () {
5513
+ const text = $(this).text()
5514
+ const link = $(this).attr('href')
5515
+ let count = 0
5516
+ let offer = {}
5517
+ if (text.includes('(') && text.includes(')')) {
5518
+ count = parseInt(text.split('(')[1].split(')')[0].trim())
5519
+ }
5520
+ if (text.startsWith('Incoming Offers')) {
5521
+ offer = IncomingOffers
5522
+ } else if (text.startsWith('Sent Offers')) {
5523
+ offer = SentOffers
5524
+ } else {
5525
+ //invalid text
5526
+ }
5527
+ offer.link = link
5528
+ offer.count = count
5529
+ })
5530
+
5531
+ const trade_offers_escrow_explanation = $('.trade_offers_escrow_explanation > .title').text().trim()
5532
+ if(trade_offers_escrow_explanation.endsWith('trade on hold') || trade_offers_escrow_explanation.endsWith('trades on hold')){
5533
+ tradeHodeCount = parseInt(trade_offers_escrow_explanation.split(' ')[0])
5534
+ }
5535
+
5536
+ $('.profile_leftcol > .tradeoffer').each(function () {
5537
+ const $1 = $(this);
5538
+ const id = $1.attr('id')
5539
+ if (id.startsWith('tradeofferid_')) {
5540
+ const tradeofferid = parseInt(id.split('tradeofferid_')[1])
5541
+ let partner = $1.html().split('ReportTradeScam(')[1].split(');')[0].trim()
5542
+ for (const s of [`"`, `'`, `"`]) {
5543
+ partner = _.trim(partner, s);
5544
+ }
5545
+ const partnerSteamId = partner.split(`',`)[0].trim()
5546
+ let partnerName = partner.split(`', "`)[1].trim();
5547
+ tradeOffers.push({
5548
+ tradeofferid, partner: {
5549
+ steamId: partnerSteamId, name: partnerName
5550
+ },
5551
+ })
5552
+ }
5553
+ })
5554
+
5555
+ return {
5556
+ IncomingOffers,
5557
+ SentOffers,
5558
+ tradeHodeCount,
5559
+ tradeOffers,
5560
+ }
5561
+ }
5562
+
5499
5563
  static parseTradeURL(tradeURL){
5500
5564
  const tradeURLParams = url.parse(tradeURL).query.split('&').reduce((accumulator, currentValue, index) => ({
5501
5565
  ...accumulator, [currentValue.split('=')[0]]: currentValue.split('=')[1]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.1.66",
3
+ "version": "1.1.67",
4
4
  "main":"index.js",
5
5
  "dependencies": {
6
6
  "axios": "^1.3.4",