mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-02-07 15:52:23 +08:00
Some more cleanup
This commit is contained in:
parent
8ffa0b50d4
commit
2b678bea06
@ -12,10 +12,10 @@ const CConfirmation = require('../classes/CConfirmation.js');
|
|||||||
* @param {SteamCommunity~getConfirmations} callback - Called when the list of confirmations is received
|
* @param {SteamCommunity~getConfirmations} callback - Called when the list of confirmations is received
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
||||||
request(this, "conf", key, time, "conf", null, false, (err, body) => {
|
request(this, 'conf', key, time, 'conf', null, false, (err, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message == "Invalid protocol: steammobile:") {
|
if (err.message == 'Invalid protocol: steammobile:') {
|
||||||
err.message = "Not Logged In";
|
err.message = 'Not Logged In';
|
||||||
this._notifySessionExpired(err);
|
this._notifySessionExpired(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
|||||||
// We have something to confirm
|
// We have something to confirm
|
||||||
let confirmations = $('#mobileconf_list');
|
let confirmations = $('#mobileconf_list');
|
||||||
if (!confirmations) {
|
if (!confirmations) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error('Malformed response'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +49,14 @@ SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
|||||||
|
|
||||||
let img = conf.find('.mobileconf_list_entry_icon img');
|
let img = conf.find('.mobileconf_list_entry_icon img');
|
||||||
confs.push(new CConfirmation(this, {
|
confs.push(new CConfirmation(this, {
|
||||||
"id": conf.data('confid'),
|
id: conf.data('confid'),
|
||||||
"type": conf.data('type'),
|
type: conf.data('type'),
|
||||||
"creator": conf.data('creator'),
|
creator: conf.data('creator'),
|
||||||
"key": conf.data('key'),
|
key: conf.data('key'),
|
||||||
"title": conf.find('.mobileconf_list_entry_description>div:nth-of-type(1)').text().trim(),
|
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(),
|
receiving: conf.find('.mobileconf_list_entry_description>div:nth-of-type(2)').text().trim(),
|
||||||
"time": conf.find('.mobileconf_list_entry_description>div:nth-of-type(3)').text().trim(),
|
time: conf.find('.mobileconf_list_entry_description>div:nth-of-type(3)').text().trim(),
|
||||||
"icon": img.length < 1 ? '' : $(img).attr('src')
|
icon: img.length < 1 ? '' : $(img).attr('src')
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,14 +78,14 @@ SteamCommunity.prototype.getConfirmations = function(time, key, callback) {
|
|||||||
* @param {SteamCommunity~getConfirmationOfferID} callback
|
* @param {SteamCommunity~getConfirmationOfferID} callback
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.getConfirmationOfferID = function(confID, time, key, callback) {
|
SteamCommunity.prototype.getConfirmationOfferID = function(confID, time, key, callback) {
|
||||||
request(this, "details/" + confID, key, time, "details", null, true, (err, body) => {
|
request(this, 'details/' + confID, key, time, 'details', null, true, (err, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!body.success) {
|
if (!body.success) {
|
||||||
callback(new Error("Cannot load confirmation details"));
|
callback(new Error('Cannot load confirmation details'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,10 +116,10 @@ SteamCommunity.prototype.getConfirmationOfferID = function(confID, time, key, ca
|
|||||||
* @param {SteamCommunity~genericErrorCallback} callback - Called when the request is complete
|
* @param {SteamCommunity~genericErrorCallback} callback - Called when the request is complete
|
||||||
*/
|
*/
|
||||||
SteamCommunity.prototype.respondToConfirmation = function(confID, confKey, time, key, accept, callback) {
|
SteamCommunity.prototype.respondToConfirmation = function(confID, confKey, time, key, accept, callback) {
|
||||||
request(this, (confID instanceof Array) ? "multiajaxop" : "ajaxop", key, time, accept ? "allow" : "cancel", {
|
request(this, (confID instanceof Array) ? 'multiajaxop' : 'ajaxop', key, time, accept ? 'allow' : 'cancel', {
|
||||||
"op": accept ? "allow" : "cancel",
|
op: accept ? 'allow' : 'cancel',
|
||||||
"cid": confID,
|
cid: confID,
|
||||||
"ck": confKey
|
ck: confKey
|
||||||
}, true, (err, body) => {
|
}, true, (err, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
@ -140,7 +140,7 @@ SteamCommunity.prototype.respondToConfirmation = function(confID, confKey, time,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(new Error("Could not act on confirmation"));
|
callback(new Error('Could not act on confirmation'));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
|
|||||||
let doConfirmation = () => {
|
let doConfirmation = () => {
|
||||||
let offset = this._timeOffset;
|
let offset = this._timeOffset;
|
||||||
let time = SteamTotp.time(offset);
|
let time = SteamTotp.time(offset);
|
||||||
this.getConfirmations(time, SteamTotp.getConfirmationKey(identitySecret, time, "conf"), (err, confs) => {
|
this.getConfirmations(time, SteamTotp.getConfirmationKey(identitySecret, time, 'conf'), (err, confs) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
@ -164,7 +164,7 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
|
|||||||
|
|
||||||
let conf = confs.find(conf => conf.creator == objectID);
|
let conf = confs.find(conf => conf.creator == objectID);
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
callback(new Error("Could not find confirmation for object " + objectID));
|
callback(new Error('Could not find confirmation for object ' + objectID));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ SteamCommunity.prototype.acceptConfirmationForObject = function(identitySecret,
|
|||||||
this._usedConfTimes.splice(0, this._usedConfTimes.length - 60); // we don't need to save more than 60 entries
|
this._usedConfTimes.splice(0, this._usedConfTimes.length - 60); // we don't need to save more than 60 entries
|
||||||
}
|
}
|
||||||
|
|
||||||
conf.respond(time, SteamTotp.getConfirmationKey(identitySecret, time, "allow"), true, callback);
|
conf.respond(time, SteamTotp.getConfirmationKey(identitySecret, time, 'allow'), true, callback);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ SteamCommunity.prototype.acceptAllConfirmations = function(time, confKey, allowK
|
|||||||
|
|
||||||
function request(community, url, key, time, tag, params, json, callback) {
|
function request(community, url, key, time, tag, params, json, callback) {
|
||||||
if (!community.steamID) {
|
if (!community.steamID) {
|
||||||
throw new Error("Must be logged in before trying to do anything with confirmations");
|
throw new Error('Must be logged in before trying to do anything with confirmations');
|
||||||
}
|
}
|
||||||
|
|
||||||
params = params || {};
|
params = params || {};
|
||||||
@ -247,16 +247,16 @@ function request(community, url, key, time, tag, params, json, callback) {
|
|||||||
params.a = community.steamID.getSteamID64();
|
params.a = community.steamID.getSteamID64();
|
||||||
params.k = key;
|
params.k = key;
|
||||||
params.t = time;
|
params.t = time;
|
||||||
params.m = "android";
|
params.m = 'android';
|
||||||
params.tag = tag;
|
params.tag = tag;
|
||||||
|
|
||||||
let req = {
|
let req = {
|
||||||
"method": url == 'multiajaxop' ? 'POST' : 'GET',
|
method: url == 'multiajaxop' ? 'POST' : 'GET',
|
||||||
"uri": "https://steamcommunity.com/mobileconf/" + url,
|
uri: 'https://steamcommunity.com/mobileconf/' + url,
|
||||||
"json": !!json
|
json: !!json
|
||||||
};
|
};
|
||||||
|
|
||||||
if (req.method == "GET") {
|
if (req.method == 'GET') {
|
||||||
req.qs = params;
|
req.qs = params;
|
||||||
} else {
|
} else {
|
||||||
req.form = params;
|
req.form = params;
|
||||||
|
@ -13,18 +13,18 @@ SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link
|
|||||||
if (!link) {
|
if (!link) {
|
||||||
if (typeof gid != 'string') {
|
if (typeof gid != 'string') {
|
||||||
// It's a SteamID object
|
// It's a SteamID object
|
||||||
link = "https://steamcommunity.com/gid/" + gid.toString() + "/memberslistxml/?xml=1";
|
link = `https://steamcommunity.com/gid/${gid.toString()}/memberslistxml/?xml=1`;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
// new SteamID could throw which is why we have this funky-looking try/catch set up here
|
// new SteamID could throw which is why we have this funky-looking try/catch set up here
|
||||||
let sid = new SteamID(gid);
|
let sid = new SteamID(gid);
|
||||||
if (sid.type == SteamID.Type.CLAN && sid.isValid()) {
|
if (sid.type == SteamID.Type.CLAN && sid.isValid()) {
|
||||||
link = "https://steamcommunity.com/gid/" + sid.getSteamID64() + "/memberslistxml/?xml=1";
|
link = `https://steamcommunity.com/gid/${sid.getSteamID64()}/memberslistxml/?xml=1`;
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Doesn't particularly matter what this message is");
|
throw new Error('Doesn\'t particularly matter what this message is');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
link = "http://steamcommunity.com/groups/" + gid + "/memberslistxml/?xml=1";
|
link = `http://steamcommunity.com/groups/${gid}/memberslistxml/?xml=1`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,10 +76,10 @@ SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64(),
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}`,
|
||||||
"form": {
|
form: {
|
||||||
"action": "join",
|
action: 'join',
|
||||||
"sessionID": this.getSessionID()
|
sessionID: this.getSessionID()
|
||||||
}
|
}
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -95,10 +95,10 @@ SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
|||||||
gid = new SteamID(gid);
|
gid = new SteamID(gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._myProfile("home_process", {
|
this._myProfile('home_process', {
|
||||||
"sessionID": this.getSessionID(),
|
sessionID: this.getSessionID(),
|
||||||
"action": "leaveGroup",
|
action: 'leaveGroup',
|
||||||
"groupId": gid.getSteamID64()
|
groupId: gid.getSteamID64()
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
@ -119,7 +119,7 @@ SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequest({
|
this.httpRequest({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/rss/`
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
@ -162,23 +162,23 @@ SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content
|
|||||||
}
|
}
|
||||||
|
|
||||||
let form = {
|
let form = {
|
||||||
"sessionID": this.getSessionID(),
|
sessionID: this.getSessionID(),
|
||||||
"action": "post",
|
action: 'post',
|
||||||
"headline": headline,
|
headline: headline,
|
||||||
"body": content,
|
body: content,
|
||||||
"languages[0][headline]": headline,
|
'languages[0][headline]': headline,
|
||||||
"languages[0][body]": content
|
'languages[0][body]': content
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
form.is_hidden = "is_hidden"
|
form.is_hidden = 'is_hidden'
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/announcements`,
|
||||||
form
|
form
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if(!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,16 +192,16 @@ SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
let submitData = {
|
let submitData = {
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/announcements`,
|
||||||
"form": {
|
form: {
|
||||||
"sessionID": this.getSessionID(),
|
sessionID: this.getSessionID(),
|
||||||
"gid": aid,
|
gid: aid,
|
||||||
"action": "update",
|
action: 'update',
|
||||||
"headline": headline,
|
headline: headline,
|
||||||
"body": content,
|
body: content,
|
||||||
"languages[0][headline]": headline,
|
'languages[0][headline]': headline,
|
||||||
"languages[0][body]": content,
|
'languages[0][body]': content,
|
||||||
"languages[0][updated]": 1
|
'languages[0][updated]': 1
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
let submitData = {
|
let 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, (err, response, body) => {
|
this.httpRequestGet(submitData, (err, response, body) => {
|
||||||
@ -257,16 +257,16 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
|||||||
}
|
}
|
||||||
|
|
||||||
let form = {
|
let form = {
|
||||||
"sessionid": this.getSessionID(),
|
sessionid: this.getSessionID(),
|
||||||
"action": "newEvent",
|
action: 'newEvent',
|
||||||
"tzOffset": new Date().getTimezoneOffset() * -60,
|
tzOffset: new Date().getTimezoneOffset() * -60,
|
||||||
"name": name,
|
name: name,
|
||||||
"type": (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
type: (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? 'GameEvent' : type),
|
||||||
"appID": (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
appID: (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
||||||
"serverIP": server.ip,
|
serverIP: server.ip,
|
||||||
"serverPassword": server.password,
|
serverPassword: server.password,
|
||||||
"notes": description,
|
notes: description,
|
||||||
"eventQuickTime": "now"
|
eventQuickTime: 'now'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (time === null) {
|
if (time === null) {
|
||||||
@ -284,7 +284,7 @@ SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, descript
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
uri: `https://steamcommunity.com/gid/${gid.toString()}/eventEdit`,
|
||||||
form
|
form
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -320,17 +320,17 @@ SteamCommunity.prototype.editGroupEvent = function(gid, id, name, type, descript
|
|||||||
}
|
}
|
||||||
|
|
||||||
let form = {
|
let form = {
|
||||||
"sessionid": this.getSessionID(),
|
sessionid: this.getSessionID(),
|
||||||
"action": "updateEvent",
|
action: 'updateEvent',
|
||||||
"eventID": id,
|
eventID: id,
|
||||||
"tzOffset": new Date().getTimezoneOffset() * -60,
|
tzOffset: new Date().getTimezoneOffset() * -60,
|
||||||
"name": name,
|
name: name,
|
||||||
"type": (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
type: (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? 'GameEvent' : type),
|
||||||
"appID": (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
appID: (typeof type == 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
||||||
"serverIP": server.ip,
|
serverIP: server.ip,
|
||||||
"serverPassword": server.password,
|
serverPassword: server.password,
|
||||||
"notes": description,
|
notes: description,
|
||||||
"eventQuickTime": "now"
|
eventQuickTime: 'now'
|
||||||
};
|
};
|
||||||
|
|
||||||
if (time === null) {
|
if (time === null) {
|
||||||
@ -348,8 +348,8 @@ SteamCommunity.prototype.editGroupEvent = function(gid, id, name, type, descript
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
uri: `https://steamcommunity.com/gid/${gid.toString()}/eventEdit`,
|
||||||
"form": form
|
form
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
@ -365,13 +365,13 @@ SteamCommunity.prototype.deleteGroupEvent = function(gid, id, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let form = {
|
let form = {
|
||||||
"sessionid": this.getSessionID(),
|
sessionid: this.getSessionID(),
|
||||||
"action": "deleteEvent",
|
action: 'deleteEvent',
|
||||||
"eventID": id
|
eventID: id
|
||||||
};
|
};
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
uri: `https://steamcommunity.com/gid/${gid.toString()}/eventEdit`,
|
||||||
form
|
form
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -392,12 +392,12 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/potwEdit",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/potwEdit`,
|
||||||
"form": {
|
form: {
|
||||||
"xml": 1,
|
xml: 1,
|
||||||
"action": "potw",
|
action: 'potw',
|
||||||
"memberId": steamID.getSteam3RenderedID(),
|
memberId: steamID.getSteam3RenderedID(),
|
||||||
"sessionid": this.getSessionID()
|
sessionid: this.getSessionID()
|
||||||
}
|
}
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -405,7 +405,7 @@ SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callba
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err || response.statusCode != 200) {
|
if (err || response.statusCode != 200) {
|
||||||
callback(err || new Error("HTTP error " + response.statusCode));
|
callback(err || new Error(`HTTP error ${response.statusCode}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,12 +434,12 @@ SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/membersManage",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/membersManage`,
|
||||||
"form": {
|
form: {
|
||||||
"sessionID": this.getSessionID(),
|
sessionID: this.getSessionID(),
|
||||||
"action": "kick",
|
action: 'kick',
|
||||||
"memberId": steamID.getSteamID64(),
|
memberId: steamID.getSteamID64(),
|
||||||
"queryString": ""
|
queryString: ''
|
||||||
}
|
}
|
||||||
}, (err, response, body) => {
|
}, (err, response, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
@ -460,7 +460,7 @@ SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequest("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/history?p=" + page, (err, response, body) => {
|
this.httpRequest(`https://steamcommunity.com/gid/${gid.getSteamID64()}/history?p=${page}`, (err, response, body) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
return;
|
return;
|
||||||
@ -535,10 +535,10 @@ SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callba
|
|||||||
}
|
}
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
"uri": "https://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/",
|
uri: `https://steamcommunity.com/comment/Clan/render/${gid.getSteamID64()}/-1/`,
|
||||||
"form": {
|
form: {
|
||||||
"start": from,
|
start: from,
|
||||||
"count": count
|
count
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -555,13 +555,13 @@ SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callba
|
|||||||
$('.commentthread_comment_content').each(function() {
|
$('.commentthread_comment_content').each(function() {
|
||||||
let comment = {};
|
let comment = {};
|
||||||
|
|
||||||
let $selector = $(this).find(".commentthread_author_link");
|
let $selector = $(this).find('.commentthread_author_link');
|
||||||
comment.authorName = $($selector).find("bdi").text();
|
comment.authorName = $($selector).find('bdi').text();
|
||||||
comment.authorId = $($selector).attr("href").replace(/https?:\/\/steamcommunity.com\/(id|profiles)\//, "");
|
comment.authorId = $($selector).attr('href').replace(/https?:\/\/steamcommunity.com\/(id|profiles)\//, '');
|
||||||
comment.date = Helpers.decodeSteamTime($(this).find(".commentthread_comment_timestamp").text().trim());
|
comment.date = Helpers.decodeSteamTime($(this).find('.commentthread_comment_timestamp').text().trim());
|
||||||
|
|
||||||
$selector = $(this).find(".commentthread_comment_text");
|
$selector = $(this).find('.commentthread_comment_text');
|
||||||
comment.commentId = $($selector).attr("id").replace("comment_content_", "");
|
comment.commentId = $($selector).attr('id').replace('comment_content_', '');
|
||||||
comment.text = $($selector).html().trim();
|
comment.text = $($selector).html().trim();
|
||||||
|
|
||||||
comments.push(comment);
|
comments.push(comment);
|
||||||
@ -581,10 +581,10 @@ SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
"uri": "https://steamcommunity.com/comment/Clan/delete/" + gid.getSteamID64() + "/-1/",
|
uri: `https://steamcommunity.com/comment/Clan/delete/${gid.getSteamID64()}/-1/`,
|
||||||
"form": {
|
form: {
|
||||||
"sessionid": this.getSessionID(),
|
sessionid: this.getSessionID(),
|
||||||
"gidcomment": cid
|
gidcomment: cid
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -603,11 +603,11 @@ SteamCommunity.prototype.postGroupComment = function(gid, message, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
"uri": "https://steamcommunity.com/comment/Clan/post/" + gid.getSteamID64() + "/-1/",
|
uri: `https://steamcommunity.com/comment/Clan/post/${gid.getSteamID64()}/-1/`,
|
||||||
"form": {
|
form: {
|
||||||
"comment": message,
|
comment: message,
|
||||||
"count": 6,
|
count: 6,
|
||||||
"sessionid": this.getSessionID()
|
sessionid: this.getSessionID()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -630,9 +630,9 @@ SteamCommunity.prototype.getGroupJoinRequests = function(gid, callback) {
|
|||||||
gid = new SteamID(gid);
|
gid = new SteamID(gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestGet("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage", (err, res, body) => {
|
this.httpRequestGet(`https://steamcommunity.com/gid/${gid.getSteamID64()}/joinRequestsManage`, (err, res, body) => {
|
||||||
if (!body) {
|
if (!body) {
|
||||||
callback(new Error("Malformed response"));
|
callback(new Error('Malformed response'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ SteamCommunity.prototype.getGroupJoinRequests = function(gid, callback) {
|
|||||||
|
|
||||||
let requests = [];
|
let requests = [];
|
||||||
for (let i = 0; i < matches.length; i++) {
|
for (let i = 0; i < matches.length; i++) {
|
||||||
requests.push(new SteamID("[U:1:" + matches[i].match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/)[1] + "]"));
|
requests.push(new SteamID('[U:1:' + matches[i].match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/)[1] + ']'));
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(null, requests);
|
callback(null, requests);
|
||||||
@ -667,21 +667,21 @@ SteamCommunity.prototype.respondToGroupJoinRequests = function(gid, steamIDs, ap
|
|||||||
let rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
|
let rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/joinRequestsManage`,
|
||||||
"form": {
|
form: {
|
||||||
"rgAccounts": rgAccounts,
|
rgAccounts: rgAccounts,
|
||||||
"bapprove": approve ? "1" : "0",
|
bapprove: approve ? '1' : '0',
|
||||||
"json": "1",
|
json: '1',
|
||||||
"sessionID": this.getSessionID()
|
sessionID: this.getSessionID()
|
||||||
},
|
},
|
||||||
"json": true
|
json: true
|
||||||
}, (err, res, body) => {
|
}, (err, res, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body != EResult.OK) {
|
if (body != EResult.OK) {
|
||||||
let err = new Error(EResult[body] || ("Error " + body));
|
let err = new Error(EResult[body] || `Error ${body}`);
|
||||||
err.eresult = body;
|
err.eresult = body;
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
@ -702,21 +702,21 @@ SteamCommunity.prototype.respondToAllGroupJoinRequests = function(gid, approve,
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.httpRequestPost({
|
this.httpRequestPost({
|
||||||
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
uri: `https://steamcommunity.com/gid/${gid.getSteamID64()}/joinRequestsManage`,
|
||||||
"form": {
|
form: {
|
||||||
"bapprove": approve ? "1" : "0",
|
bapprove: approve ? '1' : '0',
|
||||||
"json": "1",
|
json: '1',
|
||||||
"action": "bulkrespond",
|
action: 'bulkrespond',
|
||||||
"sessionID": this.getSessionID()
|
sessionID: this.getSessionID()
|
||||||
},
|
},
|
||||||
"json": true
|
json: true
|
||||||
}, (err, res, body) => {
|
}, (err, res, body) => {
|
||||||
if (!callback) {
|
if (!callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body != EResult.OK) {
|
if (body != EResult.OK) {
|
||||||
let err = new Error(EResult[body] || ("Error " + body));
|
let err = new Error(EResult[body] || `Error ${body}`);
|
||||||
err.eresult = body;
|
err.eresult = body;
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,14 +44,14 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
|||||||
let httpError = options.checkHttpError !== false && this._checkHttpError(err, response, callback, body);
|
let httpError = options.checkHttpError !== false && this._checkHttpError(err, response, callback, body);
|
||||||
let communityError = !options.json && options.checkCommunityError !== false && this._checkCommunityError(body, httpError ? noop : callback); // don't fire the callback if hasHttpError did it already
|
let communityError = !options.json && options.checkCommunityError !== false && this._checkCommunityError(body, httpError ? noop : callback); // don't fire the callback if hasHttpError did it already
|
||||||
let tradeError = !options.json && options.checkTradeError !== false && this._checkTradeError(body, httpError || communityError ? noop : callback); // don't fire the callback if either of the previous already did
|
let tradeError = !options.json && options.checkTradeError !== false && this._checkTradeError(body, httpError || communityError ? noop : callback); // don't fire the callback if either of the previous already did
|
||||||
let jsonError = options.json && options.checkJsonError !== false && !body ? new Error("Malformed JSON response") : null;
|
let jsonError = options.json && options.checkJsonError !== false && !body ? new Error('Malformed JSON response') : null;
|
||||||
|
|
||||||
this.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || jsonError || null, response, body, {
|
this.emit('postHttpRequest', requestID, source, options, httpError || communityError || tradeError || jsonError || null, response, body, {
|
||||||
"hasCallback": hasCallback,
|
hasCallback,
|
||||||
"httpError": httpError,
|
httpError,
|
||||||
"communityError": communityError,
|
communityError,
|
||||||
"tradeError": tradeError,
|
tradeError,
|
||||||
"jsonError": jsonError
|
jsonError
|
||||||
});
|
});
|
||||||
|
|
||||||
if (hasCallback && !(httpError || communityError || tradeError)) {
|
if (hasCallback && !(httpError || communityError || tradeError)) {
|
||||||
@ -71,12 +71,12 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
|||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.httpRequestGet = function() {
|
SteamCommunity.prototype.httpRequestGet = function() {
|
||||||
this._httpRequestConvenienceMethod = "GET";
|
this._httpRequestConvenienceMethod = 'GET';
|
||||||
return this.httpRequest.apply(this, arguments);
|
return this.httpRequest.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
SteamCommunity.prototype.httpRequestPost = function() {
|
SteamCommunity.prototype.httpRequestPost = function() {
|
||||||
this._httpRequestConvenienceMethod = "POST";
|
this._httpRequestConvenienceMethod = 'POST';
|
||||||
return this.httpRequest.apply(this, arguments);
|
return this.httpRequest.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,20 +91,20 @@ SteamCommunity.prototype._checkHttpError = function(err, response, callback, bod
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
if (response.statusCode >= 300 && response.statusCode <= 399 && response.headers.location.indexOf('/login') != -1) {
|
||||||
err = new Error("Not Logged In");
|
err = new Error('Not Logged In');
|
||||||
callback(err, response, body);
|
callback(err, response, body);
|
||||||
this._notifySessionExpired(err);
|
this._notifySessionExpired(err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode == 403 && typeof response.body == 'string' && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
if (response.statusCode == 403 && typeof response.body == 'string' && response.body.match(/<div id="parental_notice_instructions">Enter your PIN below to exit Family View.<\/div>/)) {
|
||||||
err = new Error("Family View Restricted");
|
err = new Error('Family View Restricted');
|
||||||
callback(err, response, body);
|
callback(err, response, body);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.statusCode >= 400) {
|
if (response.statusCode >= 400) {
|
||||||
err = new Error("HTTP error " + response.statusCode);
|
err = new Error(`HTTP error ${response.statusCode}`);
|
||||||
err.code = response.statusCode;
|
err.code = response.statusCode;
|
||||||
callback(err, response, body);
|
callback(err, response, body);
|
||||||
return err;
|
return err;
|
||||||
@ -118,13 +118,13 @@ SteamCommunity.prototype._checkCommunityError = function(html, callback) {
|
|||||||
|
|
||||||
if (typeof html == 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
|
if (typeof html == 'string' && html.match(/<h1>Sorry!<\/h1>/)) {
|
||||||
let match = html.match(/<h3>(.+)<\/h3>/);
|
let match = html.match(/<h3>(.+)<\/h3>/);
|
||||||
err = new Error(match ? match[1] : "Unknown error occurred");
|
err = new Error(match ? match[1] : 'Unknown error occurred');
|
||||||
callback(err);
|
callback(err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof html == 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
if (typeof html == 'string' && html.match(/g_steamID = false;/) && html.match(/<h1>Sign In<\/h1>/)) {
|
||||||
err = new Error("Not Logged In");
|
err = new Error('Not Logged In');
|
||||||
callback(err);
|
callback(err);
|
||||||
this._notifySessionExpired(err);
|
this._notifySessionExpired(err);
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
Reference in New Issue
Block a user