mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-28 17:20:10 +08:00
Added getGroupMembersEx and addresses param to CSteamGroup#getMembers
This commit is contained in:
parent
49b038d3d2
commit
df20c1ac25
@ -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) {
|
||||
|
@ -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);
|
||||
|
10
index.js
10
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');
|
||||
|
Loading…
Reference in New Issue
Block a user