mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-03 15:10:21 +08:00
Added HTTP source
This commit is contained in:
parent
991b11e0f4
commit
1028c4193f
@ -26,7 +26,7 @@ SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, cal
|
||||
callback(null, item);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
function CMarketItem(appid, hashName, community, body, $) {
|
||||
@ -137,7 +137,7 @@ CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) {
|
||||
if(callback) {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) {
|
||||
@ -181,5 +181,5 @@ CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback)
|
||||
}
|
||||
|
||||
callback && callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
@ -71,7 +71,7 @@ function performSearch(request, qs, results, callback) {
|
||||
qs.start += body.pagesize;
|
||||
performSearch.call(self, request, qs, results, callback);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
|
||||
function CMarketSearchResult(row) {
|
||||
|
@ -29,7 +29,7 @@ SteamCommunity.prototype.getSteamGroup = function(id, callback) {
|
||||
|
||||
callback(null, new CSteamGroup(self, result.memberList));
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
function CSteamGroup(community, groupData) {
|
||||
|
@ -48,7 +48,7 @@ SteamCommunity.prototype.getSteamUser = function(id, callback) {
|
||||
|
||||
callback(null, new CSteamUser(self, result.profile, customurl));
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
function CSteamUser(community, userData, customurl) {
|
||||
|
@ -82,7 +82,7 @@ SteamCommunity.prototype.chatLogon = function(interval, uiMode) {
|
||||
self.chatState = SteamCommunity.ChatState.LoggedOn;
|
||||
self.emit('chatLoggedOn');
|
||||
self._chatPoll();
|
||||
});
|
||||
}, "steamcommunity");
|
||||
});
|
||||
};
|
||||
|
||||
@ -127,7 +127,7 @@ SteamCommunity.prototype.chatMessage = function(recipient, text, type, callback)
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.chatLogoff = function() {
|
||||
@ -149,7 +149,7 @@ SteamCommunity.prototype.chatLogoff = function() {
|
||||
delete self.chatFriends;
|
||||
self.chatState = SteamCommunity.ChatState.Offline;
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype._chatPoll = function() {
|
||||
@ -211,7 +211,7 @@ SteamCommunity.prototype._chatPoll = function() {
|
||||
self.emit('debug', 'Unhandled chat message type: ' + message.type);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
||||
@ -242,5 +242,5 @@ SteamCommunity.prototype._chatUpdatePersona = function(steamID) {
|
||||
|
||||
self.emit('chatPersonaState', steamID, persona);
|
||||
self.chatFriends[steamID.getSteamID64()] = persona;
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
@ -158,7 +158,7 @@ function request(community, url, key, time, tag, params, json, callback) {
|
||||
}
|
||||
|
||||
callback(null, body);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
|
||||
// Confirmation checker
|
||||
|
@ -60,7 +60,7 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
|
||||
callback(null, members);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) {
|
||||
@ -94,7 +94,7 @@ SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
||||
@ -172,7 +172,7 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback
|
||||
|
||||
return callback(null, announcements);
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
|
||||
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, callback) {
|
||||
@ -205,7 +205,7 @@ SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content
|
||||
}
|
||||
|
||||
callback(null);
|
||||
})
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, content, callback) {
|
||||
@ -243,7 +243,7 @@ SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, co
|
||||
}
|
||||
|
||||
callback(null);
|
||||
})
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) {
|
||||
@ -254,8 +254,8 @@ SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback)
|
||||
var self = this;
|
||||
|
||||
var submitData = {
|
||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID(),
|
||||
}
|
||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID()
|
||||
};
|
||||
|
||||
this.httpRequestGet(submitData, function(err, response, body) {
|
||||
if(!callback) {
|
||||
@ -271,7 +271,7 @@ SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback)
|
||||
}
|
||||
|
||||
callback(null);
|
||||
})
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
||||
@ -337,7 +337,7 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
||||
@ -380,7 +380,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
|
||||
callback(new Error(results.response.results[0]));
|
||||
}
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
||||
@ -416,7 +416,7 @@ SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
||||
@ -499,5 +499,5 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
||||
});
|
||||
|
||||
callback(null, output);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
@ -1,7 +1,8 @@
|
||||
var SteamCommunity = require('../index.js');
|
||||
|
||||
SteamCommunity.prototype.httpRequest = function(uri, options, callback, method) {
|
||||
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
||||
if (typeof uri === 'object') {
|
||||
source = callback;
|
||||
callback = options;
|
||||
options = uri;
|
||||
uri = options.url || options.uri;
|
||||
@ -14,7 +15,10 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, method)
|
||||
delete this._httpRequestConvenienceMethod;
|
||||
}
|
||||
|
||||
if (this.onPreHttpRequest && this.onPreHttpRequest(options, callback) === false) {
|
||||
var requestID = ++this._httpRequestID;
|
||||
source = source || "";
|
||||
|
||||
if (this.onPreHttpRequest && this.onPreHttpRequest(requestID, source, options, callback) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -25,7 +29,7 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, method)
|
||||
var communityError = !options.json && options.checkCommunityError !== false && self._checkCommunityError(body, httpError ? function() {} : callback); // don't fire the callback if hasHttpError did it already
|
||||
var tradeError = !options.json && options.checkTradeError !== false && self._checkTradeError(body, httpError || communityError ? function() {} : callback); // don't fire the callback if either of the previous already did
|
||||
|
||||
self.emit('postHttpRequest', httpError || communityError || tradeError || null, response, body, {
|
||||
self.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || null, response, body, {
|
||||
"hasCallback": hasCallback,
|
||||
"httpError": httpError,
|
||||
"communityError": communityError,
|
||||
|
@ -122,7 +122,7 @@ SteamCommunity.prototype.getInventoryHistory = function(options, callback) {
|
||||
} else {
|
||||
callback(null, output);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
function resolveVanityURL(vanityURL, callback) {
|
||||
|
@ -21,5 +21,5 @@ SteamCommunity.prototype.getMarketApps = function(callback) {
|
||||
} else {
|
||||
callback(new Error("Malformed response"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
@ -237,7 +237,7 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
||||
}
|
||||
|
||||
doUpload(body);
|
||||
})
|
||||
}, "steamcommunity");
|
||||
} else {
|
||||
if(!format) {
|
||||
format = image.match(/\.([^\.]+)$/);
|
||||
@ -354,6 +354,6 @@ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
|
||||
if(callback) {
|
||||
callback(null, body.images.full);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
};
|
||||
|
@ -45,7 +45,7 @@ SteamCommunity.prototype.enableTwoFactor = function(callback) {
|
||||
}
|
||||
|
||||
callback(null, body.response);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
});
|
||||
};
|
||||
|
||||
@ -104,7 +104,7 @@ SteamCommunity.prototype.finalizeTwoFactor = function(secret, activationCode, ca
|
||||
} else {
|
||||
callback(null);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
};
|
||||
|
||||
@ -149,6 +149,6 @@ SteamCommunity.prototype.disableTwoFactor = function(revocationCode, callback) {
|
||||
var error = new Error("Cannot remove authenticator (" + body.response.status + ")");
|
||||
error.eresult = body.response.status;
|
||||
callback(error);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
});
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ SteamCommunity.prototype.addFriend = function(userID, callback) {
|
||||
} else {
|
||||
callback(new Error("Unknown error"));
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
||||
@ -56,7 +56,7 @@ SteamCommunity.prototype.acceptFriendRequest = function(userID, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
||||
@ -81,7 +81,7 @@ SteamCommunity.prototype.removeFriend = function(userID, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
||||
@ -106,7 +106,7 @@ SteamCommunity.prototype.blockCommunication = function(userID, callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.unblockCommunication = function(userID, callback) {
|
||||
@ -161,7 +161,7 @@ SteamCommunity.prototype.postUserComment = function(userID, message, callback) {
|
||||
} else {
|
||||
callback(new Error("Unknown error"));
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback) {
|
||||
@ -196,7 +196,7 @@ SteamCommunity.prototype.inviteUserToGroup = function(userID, groupID, callback)
|
||||
} else {
|
||||
callback(new Error("Unknown error"));
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
||||
@ -235,7 +235,7 @@ SteamCommunity.prototype.getUserInventoryContexts = function(userID, callback) {
|
||||
}
|
||||
|
||||
callback(null, data);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, tradableOnly, callback) {
|
||||
@ -298,6 +298,6 @@ SteamCommunity.prototype.getUserInventory = function(userID, appID, contextID, t
|
||||
} else {
|
||||
callback(null, inventory, currency);
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
};
|
||||
|
@ -33,9 +33,9 @@ SteamCommunity.prototype.getWebApiKey = function(domain, callback) {
|
||||
}
|
||||
|
||||
self.getWebApiKey(domain, callback);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
|
||||
@ -62,5 +62,5 @@ SteamCommunity.prototype.getWebApiOauthToken = function(callback) {
|
||||
}
|
||||
|
||||
callback(null, match[1]);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
19
index.js
19
index.js
@ -16,6 +16,7 @@ function SteamCommunity(options) {
|
||||
|
||||
this._jar = Request.jar();
|
||||
this._captchaGid = -1;
|
||||
this._httpRequestID = 0;
|
||||
this.chatState = SteamCommunity.ChatState.Offline;
|
||||
|
||||
var defaults = {
|
||||
@ -156,8 +157,8 @@ SteamCommunity.prototype.login = function(details, callback) {
|
||||
|
||||
callback(null, sessionID, cookies, steamguard, oAuth.oauth_token);
|
||||
}
|
||||
});
|
||||
});
|
||||
}, "steamcommunity");
|
||||
}, "steamcommunity");
|
||||
|
||||
function deleteMobileCookies() {
|
||||
var cookie = Request.cookie('mobileClientVersion=');
|
||||
@ -200,7 +201,7 @@ SteamCommunity.prototype.oAuthLogin = function(steamguard, token, callback) {
|
||||
|
||||
self.setCookies(cookies);
|
||||
callback(null, self.getSessionID(), cookies);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.setCookies = function(cookies) {
|
||||
@ -259,7 +260,7 @@ SteamCommunity.prototype.parentalUnlock = function(pin, callback) {
|
||||
}
|
||||
|
||||
callback();
|
||||
}.bind(this));
|
||||
}.bind(this), "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.getNotifications = function(callback) {
|
||||
@ -295,7 +296,7 @@ SteamCommunity.prototype.getNotifications = function(callback) {
|
||||
}
|
||||
|
||||
callback(null, notifications);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.resetItemNotifications = function(callback) {
|
||||
@ -310,7 +311,7 @@ SteamCommunity.prototype.resetItemNotifications = function(callback) {
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype.loggedIn = function(callback) {
|
||||
@ -326,7 +327,7 @@ SteamCommunity.prototype.loggedIn = function(callback) {
|
||||
}
|
||||
|
||||
callback(null, !!response.headers.location.match(/steamcommunity\.com(\/(id|profiles)\/[^\/]+)\/?/), false);
|
||||
});
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
|
||||
@ -353,8 +354,8 @@ SteamCommunity.prototype._myProfile = function(endpoint, form, callback) {
|
||||
options.form = form;
|
||||
}
|
||||
|
||||
self.httpRequest(options, callback);
|
||||
});
|
||||
self.httpRequest(options, callback, "steamcommunity");
|
||||
}, "steamcommunity");
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user