mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2024-12-27 15:10:14 +08:00
Pull trade offer ID directly from listing page
This commit is contained in:
parent
20785ee92b
commit
ce4d7ae026
@ -1,17 +1,32 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
|
||||
module.exports = CConfirmation;
|
||||
|
||||
function CConfirmation(community, data) {
|
||||
Object.defineProperty(this, "_community", {"value": community});
|
||||
|
||||
this.id = data.id;
|
||||
this.type = data.type;
|
||||
this.creator = data.creator;
|
||||
this.key = data.key;
|
||||
this.title = data.title;
|
||||
this.receiving = data.receiving;
|
||||
this.time = data.time;
|
||||
this.icon = data.icon;
|
||||
this.offerID = this.type == SteamCommunity.ConfirmationType.Trade ? this.creator : null;
|
||||
}
|
||||
|
||||
CConfirmation.prototype.getOfferID = function(time, key, callback) {
|
||||
if (this.type && this.creator) {
|
||||
if (this.type != SteamCommunity.ConfirmationType.Trade) {
|
||||
callback(new Error("Not a trade confirmation"));
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, this.creator);
|
||||
return;
|
||||
}
|
||||
|
||||
this._community.getConfirmationOfferID(this.id, time, key, callback);
|
||||
};
|
||||
|
||||
|
@ -52,6 +52,8 @@ SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
||||
var img = conf.find('.mobileconf_list_entry_icon img');
|
||||
confs.push(new CConfirmation(self, {
|
||||
"id": conf.data('confid'),
|
||||
"type": conf.data('type'),
|
||||
"creator": conf.data('creator'),
|
||||
"key": conf.data('key'),
|
||||
"title": conf.find('.mobileconf_list_entry_description>div:nth-of-type(1)').text().trim(),
|
||||
"receiving": conf.find('.mobileconf_list_entry_description>div:nth-of-type(2)').text().trim(),
|
||||
@ -294,24 +296,13 @@ SteamCommunity.prototype.checkConfirmations = function() {
|
||||
return; // No new ones
|
||||
}
|
||||
|
||||
// We have new confirmations! Grab a key to get details.
|
||||
self._confirmationCheckerGetKey('details', function(err, key) {
|
||||
newOnes.forEach(function(conf) {
|
||||
self._knownConfirmations[conf.id] = conf; // Add it to our list of known confirmations
|
||||
|
||||
if(err) {
|
||||
self._confirmationQueue.push(conf);
|
||||
} else {
|
||||
// Get its offer ID, if we can
|
||||
conf.getOfferID(key.time, key.key, function(err, offerID) {
|
||||
conf.offerID = offerID ? offerID : null;
|
||||
self._confirmationQueue.push(conf);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
// We have new confirmations!
|
||||
newOnes.forEach(function(conf) {
|
||||
self._knownConfirmations[conf.id] = conf; // Add it to our list of known confirmations
|
||||
self._confirmationQueue.push(conf);
|
||||
});
|
||||
|
||||
resetTimer();
|
||||
});
|
||||
});
|
||||
|
||||
|
6
index.js
6
index.js
@ -10,6 +10,12 @@ require('util').inherits(SteamCommunity, require('events').EventEmitter);
|
||||
module.exports = SteamCommunity;
|
||||
|
||||
SteamCommunity.SteamID = SteamID;
|
||||
SteamCommunity.ConfirmationType = {
|
||||
// 1 is unknown, possibly "Invalid"
|
||||
"Trade": 2,
|
||||
"MarketListing": 3
|
||||
// 4 is opt-out or other like account confirmation?
|
||||
};
|
||||
|
||||
function SteamCommunity(options) {
|
||||
options = options || {};
|
||||
|
Loading…
Reference in New Issue
Block a user