steamutils 1.1.65 → 1.1.67
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +5 -0
- package/example.js +0 -1
- package/index.js +65 -1
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -103,6 +103,7 @@ function SteamClient({
|
|
103
103
|
playersProfile: [],
|
104
104
|
partyInvite: [],
|
105
105
|
friendRelationship: [],
|
106
|
+
tradeOffers: [],
|
106
107
|
}
|
107
108
|
|
108
109
|
const gcCallback = {}
|
@@ -901,6 +902,10 @@ function SteamClient({
|
|
901
902
|
}
|
902
903
|
}
|
903
904
|
});
|
905
|
+
|
906
|
+
steamClient.on('tradeOffers', async function (count) {
|
907
|
+
callEvent(events.tradeOffers, count)
|
908
|
+
});
|
904
909
|
}
|
905
910
|
|
906
911
|
function sendFriendTyping(steamId, callback) {
|
package/example.js
CHANGED
package/index.js
CHANGED
@@ -5489,13 +5489,77 @@ class SteamUser {
|
|
5489
5489
|
})
|
5490
5490
|
return result.data
|
5491
5491
|
const resultExample = {
|
5492
|
-
tradeofferid: "
|
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]
|