diff --git a/classes/CSteamGroup.js b/classes/CSteamGroup.js index f801962..dba8372 100644 --- a/classes/CSteamGroup.js +++ b/classes/CSteamGroup.js @@ -59,8 +59,13 @@ CSteamGroup.prototype.getAvatarURL = function(size, protocol) { } }; -CSteamGroup.prototype.getMembers = function(callback) { - this._community.getGroupMembers(this.steamID, callback); +CSteamGroup.prototype.getMembers = function(addresses, callback) { + if(typeof addresses === 'function') { + callback = addresses; + addresses = null; + } + + this._community.getGroupMembers(this.steamID, callback, null, null, addresses, 0); }; CSteamGroup.prototype.join = function(callback) { diff --git a/components/groups.js b/components/groups.js index 4b93695..60ce800 100644 --- a/components/groups.js +++ b/components/groups.js @@ -1,8 +1,9 @@ var SteamCommunity = require('../index.js'); var SteamID = require('steamid'); var xml2js = require('xml2js'); +var Cheerio = require('cheerio'); -SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link) { +SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) { members = members || []; if (!link) { @@ -23,24 +24,38 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link } } + addressIdx = addressIdx || 0; + + var options = {}; + options.uri = link; + + if(addresses) { + if(addressIdx >= addresses.length) { + addressIdx = 0; + } + + options.localAddress = addresses[addressIdx]; + } + var self = this; - this.request(link, function (err, response, body) { + this.request(options, function(err, response, body) { if (self._checkHttpError(err, response, callback)) { return; } - xml2js.parseString(body, function (err, result) { + xml2js.parseString(body, function(err, result) { if (err) { callback(err); return; } - members = members.concat(result.memberList.members[0].steamID64.map(function (steamID) { + members = members.concat(result.memberList.members[0].steamID64.map(function(steamID) { return new SteamID(steamID); })); if (result.memberList.nextPageLink) { - self.getGroupMembers(gid, callback, members, result.memberList.nextPageLink); + addressIdx++; + self.getGroupMembers(gid, callback, members, result.memberList.nextPageLink, addresses, addressIdx); } else { callback(null, members); } @@ -48,6 +63,10 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link }); }; +SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) { + this.getGroupMembers(gid, callback, null, null, addresses, 0); +}; + SteamCommunity.prototype.joinGroup = function(gid, callback) { if(typeof gid === 'string') { gid = new SteamID(gid); diff --git a/index.js b/index.js index 645f4c4..3f66af5 100644 --- a/index.js +++ b/index.js @@ -9,11 +9,17 @@ module.exports = SteamCommunity; SteamCommunity.SteamID = SteamID; -function SteamCommunity() { +function SteamCommunity(localAddress) { this._jar = Request.jar(); this._captchaGid = -1; - this.request = Request.defaults({"jar": this._jar, "timeout": 50000}); this.chatState = SteamCommunity.ChatState.Offline; + + var defaults = {"jar": this._jar, "timeout": 50000}; + if(localAddress) { + defaults.localAddress = localAddress; + } + + this.request = Request.defaults(defaults); // English this._jar.setCookie(Request.cookie('Steam_Language=english'), 'https://steamcommunity.com');