steamcommunity 3.48.1 → 3.48.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +22 -22
- package/classes/CConfirmation.js +37 -37
- package/classes/CEconItem.js +120 -120
- package/classes/CSteamSharedFile.js +221 -221
- package/classes/CSteamUser.js +225 -225
- package/components/confirmations.js +428 -428
- package/components/groups.js +798 -798
- package/components/help.js +64 -64
- package/components/helpers.js +128 -128
- package/components/http.js +150 -150
- package/components/inventoryhistory.js +173 -173
- package/components/login.js +110 -110
- package/components/market.js +387 -387
- package/components/profile.js +475 -475
- package/components/sharedfiles.js +158 -158
- package/components/twofactor.js +152 -152
- package/components/users.js +1 -1
- package/components/webapi.js +221 -221
- package/examples/README.md +35 -35
- package/examples/accept_all_confirmations.js +173 -173
- package/examples/disable_twofactor.js +98 -98
- package/examples/enable_twofactor.js +143 -143
- package/index.js +2 -2
- package/package.json +1 -1
- package/resources/EChatState.js +14 -14
- package/resources/EConfirmationType.js +12 -12
- package/resources/EFriendRelationship.js +23 -23
- package/resources/EPersonaState.js +23 -23
- package/resources/EPersonaStateFlag.js +32 -32
- package/resources/EResult.js +254 -254
- package/resources/ESharedFileType.js +13 -13
package/components/groups.js
CHANGED
|
@@ -1,798 +1,798 @@
|
|
|
1
|
-
var SteamCommunity = require('../index.js');
|
|
2
|
-
var SteamID = require('steamid');
|
|
3
|
-
var xml2js = require('xml2js');
|
|
4
|
-
var Cheerio = require('cheerio');
|
|
5
|
-
var Helpers = require('./helpers.js');
|
|
6
|
-
var EResult = SteamCommunity.EResult;
|
|
7
|
-
|
|
8
|
-
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
|
9
|
-
members = members || [];
|
|
10
|
-
|
|
11
|
-
if (!link) {
|
|
12
|
-
if (typeof gid !== 'string') {
|
|
13
|
-
// It's a SteamID object
|
|
14
|
-
link = "http://steamcommunity.com/gid/" + gid.toString() + "/memberslistxml/?xml=1";
|
|
15
|
-
} else {
|
|
16
|
-
try {
|
|
17
|
-
var sid = new SteamID(gid);
|
|
18
|
-
if (sid.type == SteamID.Type.CLAN && sid.isValid()) {
|
|
19
|
-
link = "http://steamcommunity.com/gid/" + sid.getSteamID64() + "/memberslistxml/?xml=1";
|
|
20
|
-
} else {
|
|
21
|
-
throw new Error("Doesn't particularly matter what this message is");
|
|
22
|
-
}
|
|
23
|
-
} catch (e) {
|
|
24
|
-
link = "http://steamcommunity.com/groups/" + gid + "/memberslistxml/?xml=1";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
addressIdx = addressIdx || 0;
|
|
30
|
-
|
|
31
|
-
var options = {};
|
|
32
|
-
options.uri = link;
|
|
33
|
-
|
|
34
|
-
if(addresses) {
|
|
35
|
-
if(addressIdx >= addresses.length) {
|
|
36
|
-
addressIdx = 0;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
options.localAddress = addresses[addressIdx];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var self = this;
|
|
43
|
-
this.httpRequest(options, function(err, response, body) {
|
|
44
|
-
if (err) {
|
|
45
|
-
callback(err);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
xml2js.parseString(body, function(err, result) {
|
|
50
|
-
if (err) {
|
|
51
|
-
callback(err);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
members = members.concat(result.memberList.members[0].steamID64.map(function(steamID) {
|
|
56
|
-
return new SteamID(steamID);
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
if (result.memberList.nextPageLink) {
|
|
60
|
-
addressIdx++;
|
|
61
|
-
self.getGroupMembers(gid, callback, members, result.memberList.nextPageLink[0], addresses, addressIdx);
|
|
62
|
-
} else {
|
|
63
|
-
callback(null, members);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}, "steamcommunity");
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) {
|
|
70
|
-
this.getGroupMembers(gid, callback, null, null, addresses, 0);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
|
74
|
-
if(typeof gid === 'string') {
|
|
75
|
-
gid = new SteamID(gid);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var self = this;
|
|
79
|
-
this.httpRequestPost({
|
|
80
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64(),
|
|
81
|
-
"form": {
|
|
82
|
-
"action": "join",
|
|
83
|
-
"sessionID": this.getSessionID()
|
|
84
|
-
}
|
|
85
|
-
}, function(err, response, body) {
|
|
86
|
-
if(!callback) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
callback(err || null);
|
|
91
|
-
}, "steamcommunity");
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
|
95
|
-
if(typeof gid === 'string') {
|
|
96
|
-
gid = new SteamID(gid);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
var self = this;
|
|
100
|
-
this._myProfile("home_process", {
|
|
101
|
-
"sessionID": this.getSessionID(),
|
|
102
|
-
"action": "leaveGroup",
|
|
103
|
-
"groupId": gid.getSteamID64()
|
|
104
|
-
}, function(err, response, body) {
|
|
105
|
-
if(!callback) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
callback(err || null);
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback) {
|
|
114
|
-
if(typeof gid === 'string') {
|
|
115
|
-
gid = new SteamID(gid);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if(typeof time === 'function') {
|
|
119
|
-
callback = time;
|
|
120
|
-
time = new Date(0); // The beginnig of time...
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
var self = this;
|
|
124
|
-
this.httpRequest({
|
|
125
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
|
126
|
-
}, function(err, response, body) {
|
|
127
|
-
if (err) {
|
|
128
|
-
callback(err);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
xml2js.parseString(body, function(err, results) {
|
|
133
|
-
if(err) {
|
|
134
|
-
return callback(err);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if(!results.rss.channel[0].item) {
|
|
138
|
-
return callback(null, []);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
var announcements = results.rss.channel[0].item.map(function(announcement) {
|
|
142
|
-
var splitLink = announcement.link[0].split('/');
|
|
143
|
-
return {
|
|
144
|
-
headline: announcement.title[0],
|
|
145
|
-
content: announcement.description[0],
|
|
146
|
-
date: new Date(announcement.pubDate[0]),
|
|
147
|
-
author: (typeof announcement.author === 'undefined') ? null : announcement.author[0],
|
|
148
|
-
aid: splitLink[splitLink.length - 1]
|
|
149
|
-
}
|
|
150
|
-
}).filter(function(announcement) {
|
|
151
|
-
return (announcement.date > time);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
return callback(null, announcements);
|
|
155
|
-
});
|
|
156
|
-
}, "steamcommunity");
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, hidden, callback) {
|
|
160
|
-
if(typeof gid === 'string') {
|
|
161
|
-
gid = new SteamID(gid);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if(typeof hidden === 'function') {
|
|
165
|
-
callback = hidden;
|
|
166
|
-
hidden = false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var self = this;
|
|
170
|
-
var form = {
|
|
171
|
-
"sessionID": this.getSessionID(),
|
|
172
|
-
"action": "post",
|
|
173
|
-
"headline": headline,
|
|
174
|
-
"body": content,
|
|
175
|
-
"languages[0][headline]": headline,
|
|
176
|
-
"languages[0][body]": content
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
if(hidden) {
|
|
180
|
-
form.is_hidden = "is_hidden"
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
this.httpRequestPost({
|
|
184
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
|
185
|
-
form
|
|
186
|
-
}, function(err, response, body) {
|
|
187
|
-
if(!callback) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
callback(err || null);
|
|
192
|
-
}, "steamcommunity");
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, content, callback) {
|
|
196
|
-
if(typeof gid === 'string') {
|
|
197
|
-
gid = new SteamID(gid);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
var self = this;
|
|
201
|
-
|
|
202
|
-
var submitData = {
|
|
203
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
|
204
|
-
"form": {
|
|
205
|
-
"sessionID": this.getSessionID(),
|
|
206
|
-
"gid": aid,
|
|
207
|
-
"action": "update",
|
|
208
|
-
"headline": headline,
|
|
209
|
-
"body": content,
|
|
210
|
-
"languages[0][headline]": headline,
|
|
211
|
-
"languages[0][body]": content,
|
|
212
|
-
"languages[0][updated]": 1
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
this.httpRequestPost(submitData, function(err, response, body) {
|
|
217
|
-
if(!callback) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
callback(err || null);
|
|
222
|
-
}, "steamcommunity");
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) {
|
|
226
|
-
if(typeof gid === 'string') {
|
|
227
|
-
gid = new SteamID(gid);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
var self = this;
|
|
231
|
-
|
|
232
|
-
var submitData = {
|
|
233
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID()
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
this.httpRequestGet(submitData, function(err, response, body) {
|
|
237
|
-
if(!callback) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
callback(err || null);
|
|
242
|
-
}, "steamcommunity");
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
|
246
|
-
if(typeof gid === 'string') {
|
|
247
|
-
gid = new SteamID(gid);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
|
251
|
-
// Passing a number for type will make it a game event for that appid
|
|
252
|
-
|
|
253
|
-
if(typeof server === 'function') {
|
|
254
|
-
callback = server;
|
|
255
|
-
server = {"ip": "", "password": ""};
|
|
256
|
-
} else if(typeof server === 'string') {
|
|
257
|
-
server = {"ip": server, "password": ""};
|
|
258
|
-
} else if(typeof server !== 'object') {
|
|
259
|
-
server = {"ip": "", "password": ""};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
var form = {
|
|
263
|
-
"sessionid": this.getSessionID(),
|
|
264
|
-
"action": "newEvent",
|
|
265
|
-
"tzOffset": new Date().getTimezoneOffset() * -60,
|
|
266
|
-
"name": name,
|
|
267
|
-
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
|
268
|
-
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
|
269
|
-
"serverIP": server.ip,
|
|
270
|
-
"serverPassword": server.password,
|
|
271
|
-
"notes": description,
|
|
272
|
-
"eventQuickTime": "now"
|
|
273
|
-
};
|
|
274
|
-
|
|
275
|
-
if(time === null) {
|
|
276
|
-
form.startDate = 'MM/DD/YY';
|
|
277
|
-
form.startHour = '12';
|
|
278
|
-
form.startMinute = '00';
|
|
279
|
-
form.startAMPM = 'PM';
|
|
280
|
-
form.timeChoice = 'quick';
|
|
281
|
-
} else {
|
|
282
|
-
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
|
283
|
-
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
|
284
|
-
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
|
285
|
-
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
|
286
|
-
form.timeChoice = 'specific';
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
var self = this;
|
|
290
|
-
this.httpRequestPost({
|
|
291
|
-
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
292
|
-
"form": form
|
|
293
|
-
}, function(err, response, body) {
|
|
294
|
-
if(!callback) {
|
|
295
|
-
return;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
callback(err || null);
|
|
299
|
-
}, "steamcommunity");
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
SteamCommunity.prototype.editGroupEvent = function (gid, id, name, type, description, time, server, callback) {
|
|
303
|
-
if (typeof gid === 'string') {
|
|
304
|
-
gid = new SteamID(gid);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
|
308
|
-
// Passing a number for type will make it a game event for that appid
|
|
309
|
-
|
|
310
|
-
if (typeof server === 'function') {
|
|
311
|
-
callback = server;
|
|
312
|
-
server = {"ip": "", "password": ""};
|
|
313
|
-
} else if (typeof server === 'string') {
|
|
314
|
-
server = {"ip": server, "password": ""};
|
|
315
|
-
} else if (typeof server !== 'object') {
|
|
316
|
-
server = {"ip": "", "password": ""};
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
var form = {
|
|
320
|
-
"sessionid": this.getSessionID(),
|
|
321
|
-
"action": "updateEvent",
|
|
322
|
-
"eventID": id,
|
|
323
|
-
"tzOffset": new Date().getTimezoneOffset() * -60,
|
|
324
|
-
"name": name,
|
|
325
|
-
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
|
326
|
-
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
|
327
|
-
"serverIP": server.ip,
|
|
328
|
-
"serverPassword": server.password,
|
|
329
|
-
"notes": description,
|
|
330
|
-
"eventQuickTime": "now"
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
if (time === null) {
|
|
334
|
-
form.startDate = 'MM/DD/YY';
|
|
335
|
-
form.startHour = '12';
|
|
336
|
-
form.startMinute = '00';
|
|
337
|
-
form.startAMPM = 'PM';
|
|
338
|
-
form.timeChoice = 'quick';
|
|
339
|
-
} else {
|
|
340
|
-
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
|
341
|
-
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
|
342
|
-
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
|
343
|
-
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
|
344
|
-
form.timeChoice = 'specific';
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var self = this;
|
|
348
|
-
this.httpRequestPost({
|
|
349
|
-
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
350
|
-
"form": form
|
|
351
|
-
}, function(err, response, body) {
|
|
352
|
-
if(!callback) {
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
callback(err || null);
|
|
357
|
-
}, "steamcommunity");
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
SteamCommunity.prototype.deleteGroupEvent = function(gid, id, callback) {
|
|
361
|
-
if (typeof gid === 'string') {
|
|
362
|
-
gid = new SteamID(gid);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var form = {
|
|
366
|
-
"sessionid": this.getSessionID(),
|
|
367
|
-
"action": "deleteEvent",
|
|
368
|
-
"eventID": id
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
var self = this;
|
|
372
|
-
this.httpRequestPost({
|
|
373
|
-
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
374
|
-
"form": form
|
|
375
|
-
}, function(err, response, body) {
|
|
376
|
-
if(!callback) {
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
callback(err || null);
|
|
381
|
-
}, "steamcommunity");
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
|
385
|
-
if(typeof gid === 'string') {
|
|
386
|
-
gid = new SteamID(gid);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if(typeof steamID === 'string') {
|
|
390
|
-
steamID = new SteamID(steamID);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
var self = this;
|
|
394
|
-
this.httpRequestPost({
|
|
395
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/potwEdit",
|
|
396
|
-
"form": {
|
|
397
|
-
"xml": 1,
|
|
398
|
-
"action": "potw",
|
|
399
|
-
"memberId": steamID.getSteam3RenderedID(),
|
|
400
|
-
"sessionid": this.getSessionID()
|
|
401
|
-
}
|
|
402
|
-
}, function(err, response, body) {
|
|
403
|
-
if(!callback) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if(err || response.statusCode != 200) {
|
|
408
|
-
callback(err || new Error("HTTP error " + response.statusCode));
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
xml2js.parseString(body, function(err, results) {
|
|
413
|
-
if(err) {
|
|
414
|
-
callback(err);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
if(results.response.results[0] == 'OK') {
|
|
419
|
-
callback(null, new SteamID(results.response.oldPOTW[0]), new SteamID(results.response.newPOTW[0]));
|
|
420
|
-
} else {
|
|
421
|
-
callback(new Error(results.response.results[0]));
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}, "steamcommunity");
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
|
428
|
-
if(typeof gid === 'string') {
|
|
429
|
-
gid = new SteamID(gid);
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if(typeof steamID === 'string') {
|
|
433
|
-
steamID = new SteamID(steamID);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
var self = this;
|
|
437
|
-
this.httpRequestPost({
|
|
438
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/membersManage",
|
|
439
|
-
"form": {
|
|
440
|
-
"sessionID": this.getSessionID(),
|
|
441
|
-
"action": "kick",
|
|
442
|
-
"memberId": steamID.getSteamID64(),
|
|
443
|
-
"queryString": ""
|
|
444
|
-
}
|
|
445
|
-
}, function(err, response, body) {
|
|
446
|
-
if(!callback) {
|
|
447
|
-
return;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
callback(err || null);
|
|
451
|
-
}, "steamcommunity");
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|
455
|
-
if(typeof gid === 'string') {
|
|
456
|
-
gid = new SteamID(gid);
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if(typeof page === 'function') {
|
|
460
|
-
callback = page;
|
|
461
|
-
page = 1;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
var self = this;
|
|
465
|
-
this.httpRequest("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/history?p=" + page, function(err, response, body) {
|
|
466
|
-
if (err) {
|
|
467
|
-
callback(err);
|
|
468
|
-
return;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
var $ = Cheerio.load(body);
|
|
472
|
-
var output = {};
|
|
473
|
-
|
|
474
|
-
var paging = $('.group_paging p').text();
|
|
475
|
-
var match = paging.match(/(\d+) - (\d+) of (\d+)/);
|
|
476
|
-
|
|
477
|
-
if(match) {
|
|
478
|
-
output.first = parseInt(match[1], 10);
|
|
479
|
-
output.last = parseInt(match[2], 10);
|
|
480
|
-
output.total = parseInt(match[3], 10);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
output.items = [];
|
|
484
|
-
var currentYear = (new Date()).getFullYear();
|
|
485
|
-
var lastDate = Date.now();
|
|
486
|
-
|
|
487
|
-
Array.prototype.forEach.call($('.historyItem, .historyItemb'), function(item) {
|
|
488
|
-
var data = {};
|
|
489
|
-
|
|
490
|
-
var $item = $(item);
|
|
491
|
-
data.type = $item.find('.historyShort').text().replace(/ /g, '');
|
|
492
|
-
|
|
493
|
-
var users = $item.find('.whiteLink[data-miniprofile]');
|
|
494
|
-
var sid;
|
|
495
|
-
if(users[0]) {
|
|
496
|
-
sid = new SteamID();
|
|
497
|
-
sid.universe = SteamID.Universe.PUBLIC;
|
|
498
|
-
sid.type = SteamID.Type.INDIVIDUAL;
|
|
499
|
-
sid.instance = SteamID.Instance.DESKTOP;
|
|
500
|
-
sid.accountid = $(users[0]).data('miniprofile');
|
|
501
|
-
data.user = sid;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if(users[1]) {
|
|
505
|
-
sid = new SteamID();
|
|
506
|
-
sid.universe = SteamID.Universe.PUBLIC;
|
|
507
|
-
sid.type = SteamID.Type.INDIVIDUAL;
|
|
508
|
-
sid.instance = SteamID.Instance.DESKTOP;
|
|
509
|
-
sid.accountid = $(users[1]).data('miniprofile');
|
|
510
|
-
data.actor = sid;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// Figure out the date. Of course there's no year, because Valve
|
|
514
|
-
var dateParts = $item.find('.historyDate').text().split('@');
|
|
515
|
-
var date = dateParts[0].trim().replace(/(st|nd|th)$/, '').trim() + ', ' + currentYear;
|
|
516
|
-
var time = dateParts[1].trim().replace(/(am|pm)/, ' $1');
|
|
517
|
-
|
|
518
|
-
date = new Date(date + ' ' + time + ' UTC');
|
|
519
|
-
|
|
520
|
-
// If this date is in the future, or it's later than the previous one, decrement the year
|
|
521
|
-
if(date.getTime() > lastDate) {
|
|
522
|
-
date.setFullYear(date.getFullYear() - 1);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
data.date = date;
|
|
526
|
-
|
|
527
|
-
output.items.push(data);
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
callback(null, output);
|
|
531
|
-
}, "steamcommunity");
|
|
532
|
-
};
|
|
533
|
-
|
|
534
|
-
SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callback) {
|
|
535
|
-
if (typeof gid === 'string') {
|
|
536
|
-
gid = new SteamID(gid);
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
var options = {
|
|
540
|
-
"uri": "https://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/",
|
|
541
|
-
"form": {
|
|
542
|
-
"start": from,
|
|
543
|
-
"count": count
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
var self = this;
|
|
548
|
-
this.httpRequestPost(options, function(err, response, body) {
|
|
549
|
-
if (err) {
|
|
550
|
-
callback(err);
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
var comments = [];
|
|
555
|
-
|
|
556
|
-
var $ = Cheerio.load(JSON.parse(body).comments_html);
|
|
557
|
-
|
|
558
|
-
$(".commentthread_comment_content").each(function () {
|
|
559
|
-
var comment = {};
|
|
560
|
-
var cachedSelector;
|
|
561
|
-
|
|
562
|
-
var $selector = $(this).find(".commentthread_author_link");
|
|
563
|
-
comment.authorName = $($selector).find("bdi").text();
|
|
564
|
-
comment.authorId = $($selector).attr("href").replace(/https?:\/\/steamcommunity.com\/(id|profiles)\//, "");
|
|
565
|
-
comment.date = Helpers.decodeSteamTime($(this).find(".commentthread_comment_timestamp").text().trim());
|
|
566
|
-
|
|
567
|
-
$selector = $(this).find(".commentthread_comment_text");
|
|
568
|
-
comment.commentId = $($selector).attr("id").replace("comment_content_", "");
|
|
569
|
-
comment.text = $($selector).html().trim();
|
|
570
|
-
|
|
571
|
-
comments.push(comment);
|
|
572
|
-
});
|
|
573
|
-
|
|
574
|
-
callback(null, comments);
|
|
575
|
-
}, "steamcommunity");
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) {
|
|
579
|
-
if (typeof gid === 'string') {
|
|
580
|
-
gid = new SteamID(gid);
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
if (typeof cid !== 'string') {
|
|
584
|
-
cid = cid.toString();
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
var options = {
|
|
588
|
-
"uri": "https://steamcommunity.com/comment/Clan/delete/" + gid.getSteamID64() + "/-1/",
|
|
589
|
-
"form": {
|
|
590
|
-
"sessionid": this.getSessionID(),
|
|
591
|
-
"gidcomment": cid
|
|
592
|
-
}
|
|
593
|
-
};
|
|
594
|
-
|
|
595
|
-
var self = this;
|
|
596
|
-
this.httpRequestPost(options, function(err, response, body) {
|
|
597
|
-
if(!callback) {
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
callback(err || null);
|
|
602
|
-
}, "steamcommunity");
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
SteamCommunity.prototype.postGroupComment = function(gid, message, callback) {
|
|
606
|
-
if (typeof gid === 'string') {
|
|
607
|
-
gid = new SteamID(gid);
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
var options = {
|
|
611
|
-
"uri": "https://steamcommunity.com/comment/Clan/post/" + gid.getSteamID64() + "/-1/",
|
|
612
|
-
"form": {
|
|
613
|
-
"comment": message,
|
|
614
|
-
"count": 6,
|
|
615
|
-
"sessionid": this.getSessionID()
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
|
|
619
|
-
var self = this;
|
|
620
|
-
this.httpRequestPost(options, function(err, response, body) {
|
|
621
|
-
if(!callback) {
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
callback(err || null);
|
|
626
|
-
}, "steamcommunity");
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Get requests to join a restricted group.
|
|
631
|
-
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
632
|
-
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
|
633
|
-
*/
|
|
634
|
-
SteamCommunity.prototype.getGroupJoinRequests = function(gid, callback) {
|
|
635
|
-
if (typeof gid === 'string') {
|
|
636
|
-
gid = new SteamID(gid);
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
this.httpRequestGet("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage", (err, res, body) => {
|
|
640
|
-
if (!body) {
|
|
641
|
-
callback(new Error("Malformed response"));
|
|
642
|
-
return;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
var matches = body.match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/g);
|
|
646
|
-
if (!matches) {
|
|
647
|
-
// no pending requests
|
|
648
|
-
callback(null, []);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
var requests = [];
|
|
653
|
-
for (var i = 0; i < matches.length; i++) {
|
|
654
|
-
requests.push(new SteamID("[U:1:" + matches[i].match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/)[1] + "]"));
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
callback(null, requests);
|
|
658
|
-
}, "steamcommunity");
|
|
659
|
-
};
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Respond to one or more join requests to a restricted group.
|
|
663
|
-
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
664
|
-
* @param {SteamID|string|SteamID[]|string[]} steamIDs - The SteamIDs of the users you want to approve or deny membership for (or a single value)
|
|
665
|
-
* @param {boolean} approve - True to put them in the group, false to deny their membership
|
|
666
|
-
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
667
|
-
*/
|
|
668
|
-
SteamCommunity.prototype.respondToGroupJoinRequests = function(gid, steamIDs, approve, callback) {
|
|
669
|
-
if (typeof gid === 'string') {
|
|
670
|
-
gid = new SteamID(gid);
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
var rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
|
|
674
|
-
|
|
675
|
-
this.httpRequestPost({
|
|
676
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
|
677
|
-
"form": {
|
|
678
|
-
"rgAccounts": rgAccounts,
|
|
679
|
-
"bapprove": approve ? "1" : "0",
|
|
680
|
-
"json": "1",
|
|
681
|
-
"sessionID": this.getSessionID()
|
|
682
|
-
},
|
|
683
|
-
"json": true
|
|
684
|
-
}, (err, res, body) => {
|
|
685
|
-
if (!callback) {
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
if (body != EResult.OK) {
|
|
690
|
-
var err = new Error(EResult[body] || ("Error " + body));
|
|
691
|
-
err.eresult = body;
|
|
692
|
-
callback(err);
|
|
693
|
-
} else {
|
|
694
|
-
callback(null);
|
|
695
|
-
}
|
|
696
|
-
}, "steamcommunity");
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* Respond to *ALL* pending group-join requests for a particular group.
|
|
701
|
-
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
702
|
-
* @param {boolean} approve - True to allow everyone who requested into the group, false to not
|
|
703
|
-
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
704
|
-
*/
|
|
705
|
-
SteamCommunity.prototype.respondToAllGroupJoinRequests = function(gid, approve, callback) {
|
|
706
|
-
if (typeof gid === 'string') {
|
|
707
|
-
gid = new SteamID(gid);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
this.httpRequestPost({
|
|
711
|
-
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
|
712
|
-
"form": {
|
|
713
|
-
"bapprove": approve ? "1" : "0",
|
|
714
|
-
"json": "1",
|
|
715
|
-
"action": "bulkrespond",
|
|
716
|
-
"sessionID": this.getSessionID()
|
|
717
|
-
},
|
|
718
|
-
"json": true
|
|
719
|
-
}, (err, res, body) => {
|
|
720
|
-
if (!callback) {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
if (body != EResult.OK) {
|
|
725
|
-
var err = new Error(EResult[body] || ("Error " + body));
|
|
726
|
-
err.eresult = body;
|
|
727
|
-
callback(err);
|
|
728
|
-
} else {
|
|
729
|
-
callback(null);
|
|
730
|
-
}
|
|
731
|
-
}, "steamcommunity");
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
/**
|
|
735
|
-
* Follows a curator page
|
|
736
|
-
* @param {string|number} curatorId - ID of the curator (not a SteamID)
|
|
737
|
-
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
738
|
-
*/
|
|
739
|
-
SteamCommunity.prototype.followCurator = function(curatorId, callback) {
|
|
740
|
-
this.httpRequestPost({
|
|
741
|
-
"uri": "https://store.steampowered.com/curators/ajaxfollow",
|
|
742
|
-
"form": {
|
|
743
|
-
"clanid": curatorId,
|
|
744
|
-
"sessionid": this.getSessionID(),
|
|
745
|
-
"follow": 1
|
|
746
|
-
},
|
|
747
|
-
"json": true
|
|
748
|
-
}, (err, res, body) => {
|
|
749
|
-
if (!callback) {
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
if (err) {
|
|
754
|
-
callback(err);
|
|
755
|
-
return;
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
if (body.success && body.success.success != SteamCommunity.EResult.OK) {
|
|
759
|
-
callback(Helpers.eresultError(body.success.success));
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
callback(null);
|
|
764
|
-
}, "steamcommunity");
|
|
765
|
-
};
|
|
766
|
-
|
|
767
|
-
/**
|
|
768
|
-
* Unfollows a curator page
|
|
769
|
-
* @param {string|number} curatorId - ID of the curator (not a SteamID)
|
|
770
|
-
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
771
|
-
*/
|
|
772
|
-
SteamCommunity.prototype.unfollowCurator = function(curatorId, callback) {
|
|
773
|
-
this.httpRequestPost({
|
|
774
|
-
"uri": "https://store.steampowered.com/curators/ajaxfollow",
|
|
775
|
-
"form": {
|
|
776
|
-
"clanid": curatorId,
|
|
777
|
-
"sessionid": this.getSessionID(),
|
|
778
|
-
"follow": 0
|
|
779
|
-
},
|
|
780
|
-
"json": true
|
|
781
|
-
}, (err, res, body) => {
|
|
782
|
-
if (!callback) {
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
if (err) {
|
|
787
|
-
callback(err);
|
|
788
|
-
return;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (body.success && body.success.success != SteamCommunity.EResult.OK) {
|
|
792
|
-
callback(Helpers.eresultError(body.success.success));
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
callback(null);
|
|
797
|
-
}, "steamcommunity");
|
|
798
|
-
};
|
|
1
|
+
var SteamCommunity = require('../index.js');
|
|
2
|
+
var SteamID = require('steamid');
|
|
3
|
+
var xml2js = require('xml2js');
|
|
4
|
+
var Cheerio = require('cheerio');
|
|
5
|
+
var Helpers = require('./helpers.js');
|
|
6
|
+
var EResult = SteamCommunity.EResult;
|
|
7
|
+
|
|
8
|
+
SteamCommunity.prototype.getGroupMembers = function(gid, callback, members, link, addresses, addressIdx) {
|
|
9
|
+
members = members || [];
|
|
10
|
+
|
|
11
|
+
if (!link) {
|
|
12
|
+
if (typeof gid !== 'string') {
|
|
13
|
+
// It's a SteamID object
|
|
14
|
+
link = "http://steamcommunity.com/gid/" + gid.toString() + "/memberslistxml/?xml=1";
|
|
15
|
+
} else {
|
|
16
|
+
try {
|
|
17
|
+
var sid = new SteamID(gid);
|
|
18
|
+
if (sid.type == SteamID.Type.CLAN && sid.isValid()) {
|
|
19
|
+
link = "http://steamcommunity.com/gid/" + sid.getSteamID64() + "/memberslistxml/?xml=1";
|
|
20
|
+
} else {
|
|
21
|
+
throw new Error("Doesn't particularly matter what this message is");
|
|
22
|
+
}
|
|
23
|
+
} catch (e) {
|
|
24
|
+
link = "http://steamcommunity.com/groups/" + gid + "/memberslistxml/?xml=1";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
addressIdx = addressIdx || 0;
|
|
30
|
+
|
|
31
|
+
var options = {};
|
|
32
|
+
options.uri = link;
|
|
33
|
+
|
|
34
|
+
if(addresses) {
|
|
35
|
+
if(addressIdx >= addresses.length) {
|
|
36
|
+
addressIdx = 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
options.localAddress = addresses[addressIdx];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var self = this;
|
|
43
|
+
this.httpRequest(options, function(err, response, body) {
|
|
44
|
+
if (err) {
|
|
45
|
+
callback(err);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
xml2js.parseString(body, function(err, result) {
|
|
50
|
+
if (err) {
|
|
51
|
+
callback(err);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
members = members.concat(result.memberList.members[0].steamID64.map(function(steamID) {
|
|
56
|
+
return new SteamID(steamID);
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
if (result.memberList.nextPageLink) {
|
|
60
|
+
addressIdx++;
|
|
61
|
+
self.getGroupMembers(gid, callback, members, result.memberList.nextPageLink[0], addresses, addressIdx);
|
|
62
|
+
} else {
|
|
63
|
+
callback(null, members);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, "steamcommunity");
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
SteamCommunity.prototype.getGroupMembersEx = function(gid, addresses, callback) {
|
|
70
|
+
this.getGroupMembers(gid, callback, null, null, addresses, 0);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
SteamCommunity.prototype.joinGroup = function(gid, callback) {
|
|
74
|
+
if(typeof gid === 'string') {
|
|
75
|
+
gid = new SteamID(gid);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var self = this;
|
|
79
|
+
this.httpRequestPost({
|
|
80
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64(),
|
|
81
|
+
"form": {
|
|
82
|
+
"action": "join",
|
|
83
|
+
"sessionID": this.getSessionID()
|
|
84
|
+
}
|
|
85
|
+
}, function(err, response, body) {
|
|
86
|
+
if(!callback) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
callback(err || null);
|
|
91
|
+
}, "steamcommunity");
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
SteamCommunity.prototype.leaveGroup = function(gid, callback) {
|
|
95
|
+
if(typeof gid === 'string') {
|
|
96
|
+
gid = new SteamID(gid);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var self = this;
|
|
100
|
+
this._myProfile("home_process", {
|
|
101
|
+
"sessionID": this.getSessionID(),
|
|
102
|
+
"action": "leaveGroup",
|
|
103
|
+
"groupId": gid.getSteamID64()
|
|
104
|
+
}, function(err, response, body) {
|
|
105
|
+
if(!callback) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
callback(err || null);
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
SteamCommunity.prototype.getAllGroupAnnouncements = function(gid, time, callback) {
|
|
114
|
+
if(typeof gid === 'string') {
|
|
115
|
+
gid = new SteamID(gid);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if(typeof time === 'function') {
|
|
119
|
+
callback = time;
|
|
120
|
+
time = new Date(0); // The beginnig of time...
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
var self = this;
|
|
124
|
+
this.httpRequest({
|
|
125
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/rss/"
|
|
126
|
+
}, function(err, response, body) {
|
|
127
|
+
if (err) {
|
|
128
|
+
callback(err);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
xml2js.parseString(body, function(err, results) {
|
|
133
|
+
if(err) {
|
|
134
|
+
return callback(err);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if(!results.rss.channel[0].item) {
|
|
138
|
+
return callback(null, []);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
var announcements = results.rss.channel[0].item.map(function(announcement) {
|
|
142
|
+
var splitLink = announcement.link[0].split('/');
|
|
143
|
+
return {
|
|
144
|
+
headline: announcement.title[0],
|
|
145
|
+
content: announcement.description[0],
|
|
146
|
+
date: new Date(announcement.pubDate[0]),
|
|
147
|
+
author: (typeof announcement.author === 'undefined') ? null : announcement.author[0],
|
|
148
|
+
aid: splitLink[splitLink.length - 1]
|
|
149
|
+
}
|
|
150
|
+
}).filter(function(announcement) {
|
|
151
|
+
return (announcement.date > time);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return callback(null, announcements);
|
|
155
|
+
});
|
|
156
|
+
}, "steamcommunity");
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
SteamCommunity.prototype.postGroupAnnouncement = function(gid, headline, content, hidden, callback) {
|
|
160
|
+
if(typeof gid === 'string') {
|
|
161
|
+
gid = new SteamID(gid);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if(typeof hidden === 'function') {
|
|
165
|
+
callback = hidden;
|
|
166
|
+
hidden = false;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var self = this;
|
|
170
|
+
var form = {
|
|
171
|
+
"sessionID": this.getSessionID(),
|
|
172
|
+
"action": "post",
|
|
173
|
+
"headline": headline,
|
|
174
|
+
"body": content,
|
|
175
|
+
"languages[0][headline]": headline,
|
|
176
|
+
"languages[0][body]": content
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if(hidden) {
|
|
180
|
+
form.is_hidden = "is_hidden"
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
this.httpRequestPost({
|
|
184
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
|
185
|
+
form
|
|
186
|
+
}, function(err, response, body) {
|
|
187
|
+
if(!callback) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
callback(err || null);
|
|
192
|
+
}, "steamcommunity");
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
SteamCommunity.prototype.editGroupAnnouncement = function(gid, aid, headline, content, callback) {
|
|
196
|
+
if(typeof gid === 'string') {
|
|
197
|
+
gid = new SteamID(gid);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
var self = this;
|
|
201
|
+
|
|
202
|
+
var submitData = {
|
|
203
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements",
|
|
204
|
+
"form": {
|
|
205
|
+
"sessionID": this.getSessionID(),
|
|
206
|
+
"gid": aid,
|
|
207
|
+
"action": "update",
|
|
208
|
+
"headline": headline,
|
|
209
|
+
"body": content,
|
|
210
|
+
"languages[0][headline]": headline,
|
|
211
|
+
"languages[0][body]": content,
|
|
212
|
+
"languages[0][updated]": 1
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
this.httpRequestPost(submitData, function(err, response, body) {
|
|
217
|
+
if(!callback) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
callback(err || null);
|
|
222
|
+
}, "steamcommunity");
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
SteamCommunity.prototype.deleteGroupAnnouncement = function(gid, aid, callback) {
|
|
226
|
+
if(typeof gid === 'string') {
|
|
227
|
+
gid = new SteamID(gid);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var self = this;
|
|
231
|
+
|
|
232
|
+
var submitData = {
|
|
233
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/announcements/delete/" + aid + "?sessionID=" + this.getSessionID()
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
this.httpRequestGet(submitData, function(err, response, body) {
|
|
237
|
+
if(!callback) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
callback(err || null);
|
|
242
|
+
}, "steamcommunity");
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
SteamCommunity.prototype.scheduleGroupEvent = function(gid, name, type, description, time, server, callback) {
|
|
246
|
+
if(typeof gid === 'string') {
|
|
247
|
+
gid = new SteamID(gid);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
|
251
|
+
// Passing a number for type will make it a game event for that appid
|
|
252
|
+
|
|
253
|
+
if(typeof server === 'function') {
|
|
254
|
+
callback = server;
|
|
255
|
+
server = {"ip": "", "password": ""};
|
|
256
|
+
} else if(typeof server === 'string') {
|
|
257
|
+
server = {"ip": server, "password": ""};
|
|
258
|
+
} else if(typeof server !== 'object') {
|
|
259
|
+
server = {"ip": "", "password": ""};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
var form = {
|
|
263
|
+
"sessionid": this.getSessionID(),
|
|
264
|
+
"action": "newEvent",
|
|
265
|
+
"tzOffset": new Date().getTimezoneOffset() * -60,
|
|
266
|
+
"name": name,
|
|
267
|
+
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
|
268
|
+
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
|
269
|
+
"serverIP": server.ip,
|
|
270
|
+
"serverPassword": server.password,
|
|
271
|
+
"notes": description,
|
|
272
|
+
"eventQuickTime": "now"
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
if(time === null) {
|
|
276
|
+
form.startDate = 'MM/DD/YY';
|
|
277
|
+
form.startHour = '12';
|
|
278
|
+
form.startMinute = '00';
|
|
279
|
+
form.startAMPM = 'PM';
|
|
280
|
+
form.timeChoice = 'quick';
|
|
281
|
+
} else {
|
|
282
|
+
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
|
283
|
+
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
|
284
|
+
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
|
285
|
+
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
|
286
|
+
form.timeChoice = 'specific';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
var self = this;
|
|
290
|
+
this.httpRequestPost({
|
|
291
|
+
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
292
|
+
"form": form
|
|
293
|
+
}, function(err, response, body) {
|
|
294
|
+
if(!callback) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
callback(err || null);
|
|
299
|
+
}, "steamcommunity");
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
SteamCommunity.prototype.editGroupEvent = function (gid, id, name, type, description, time, server, callback) {
|
|
303
|
+
if (typeof gid === 'string') {
|
|
304
|
+
gid = new SteamID(gid);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Event types: ChatEvent - Chat, OtherEvent - A lil somethin somethin, PartyEvent - Party!, MeetingEvent - Important meeting, SpecialCauseEvent - Special cause (charity ball?), MusicAndArtsEvent - Music or Art type thing, SportsEvent - Sporting endeavor, TripEvent - Out of town excursion
|
|
308
|
+
// Passing a number for type will make it a game event for that appid
|
|
309
|
+
|
|
310
|
+
if (typeof server === 'function') {
|
|
311
|
+
callback = server;
|
|
312
|
+
server = {"ip": "", "password": ""};
|
|
313
|
+
} else if (typeof server === 'string') {
|
|
314
|
+
server = {"ip": server, "password": ""};
|
|
315
|
+
} else if (typeof server !== 'object') {
|
|
316
|
+
server = {"ip": "", "password": ""};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var form = {
|
|
320
|
+
"sessionid": this.getSessionID(),
|
|
321
|
+
"action": "updateEvent",
|
|
322
|
+
"eventID": id,
|
|
323
|
+
"tzOffset": new Date().getTimezoneOffset() * -60,
|
|
324
|
+
"name": name,
|
|
325
|
+
"type": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? "GameEvent" : type),
|
|
326
|
+
"appID": (typeof type === 'number' || !isNaN(parseInt(type, 10)) ? type : ''),
|
|
327
|
+
"serverIP": server.ip,
|
|
328
|
+
"serverPassword": server.password,
|
|
329
|
+
"notes": description,
|
|
330
|
+
"eventQuickTime": "now"
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
if (time === null) {
|
|
334
|
+
form.startDate = 'MM/DD/YY';
|
|
335
|
+
form.startHour = '12';
|
|
336
|
+
form.startMinute = '00';
|
|
337
|
+
form.startAMPM = 'PM';
|
|
338
|
+
form.timeChoice = 'quick';
|
|
339
|
+
} else {
|
|
340
|
+
form.startDate = (time.getMonth() + 1 < 10 ? '0' : '') + (time.getMonth() + 1) + '/' + (time.getDate() < 10 ? '0' : '') + time.getDate() + '/' + time.getFullYear().toString().substring(2);
|
|
341
|
+
form.startHour = (time.getHours() === 0 ? '12' : (time.getHours() > 12 ? time.getHours() - 12 : time.getHours()));
|
|
342
|
+
form.startMinute = (time.getMinutes() < 10 ? '0' : '') + time.getMinutes();
|
|
343
|
+
form.startAMPM = (time.getHours() <= 12 ? 'AM' : 'PM');
|
|
344
|
+
form.timeChoice = 'specific';
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var self = this;
|
|
348
|
+
this.httpRequestPost({
|
|
349
|
+
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
350
|
+
"form": form
|
|
351
|
+
}, function(err, response, body) {
|
|
352
|
+
if(!callback) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
callback(err || null);
|
|
357
|
+
}, "steamcommunity");
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
SteamCommunity.prototype.deleteGroupEvent = function(gid, id, callback) {
|
|
361
|
+
if (typeof gid === 'string') {
|
|
362
|
+
gid = new SteamID(gid);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
var form = {
|
|
366
|
+
"sessionid": this.getSessionID(),
|
|
367
|
+
"action": "deleteEvent",
|
|
368
|
+
"eventID": id
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
var self = this;
|
|
372
|
+
this.httpRequestPost({
|
|
373
|
+
"uri": "https://steamcommunity.com/gid/" + gid.toString() + "/eventEdit",
|
|
374
|
+
"form": form
|
|
375
|
+
}, function(err, response, body) {
|
|
376
|
+
if(!callback) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
callback(err || null);
|
|
381
|
+
}, "steamcommunity");
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
SteamCommunity.prototype.setGroupPlayerOfTheWeek = function(gid, steamID, callback) {
|
|
385
|
+
if(typeof gid === 'string') {
|
|
386
|
+
gid = new SteamID(gid);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if(typeof steamID === 'string') {
|
|
390
|
+
steamID = new SteamID(steamID);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
var self = this;
|
|
394
|
+
this.httpRequestPost({
|
|
395
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/potwEdit",
|
|
396
|
+
"form": {
|
|
397
|
+
"xml": 1,
|
|
398
|
+
"action": "potw",
|
|
399
|
+
"memberId": steamID.getSteam3RenderedID(),
|
|
400
|
+
"sessionid": this.getSessionID()
|
|
401
|
+
}
|
|
402
|
+
}, function(err, response, body) {
|
|
403
|
+
if(!callback) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if(err || response.statusCode != 200) {
|
|
408
|
+
callback(err || new Error("HTTP error " + response.statusCode));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
xml2js.parseString(body, function(err, results) {
|
|
413
|
+
if(err) {
|
|
414
|
+
callback(err);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if(results.response.results[0] == 'OK') {
|
|
419
|
+
callback(null, new SteamID(results.response.oldPOTW[0]), new SteamID(results.response.newPOTW[0]));
|
|
420
|
+
} else {
|
|
421
|
+
callback(new Error(results.response.results[0]));
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
}, "steamcommunity");
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
SteamCommunity.prototype.kickGroupMember = function(gid, steamID, callback) {
|
|
428
|
+
if(typeof gid === 'string') {
|
|
429
|
+
gid = new SteamID(gid);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if(typeof steamID === 'string') {
|
|
433
|
+
steamID = new SteamID(steamID);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
var self = this;
|
|
437
|
+
this.httpRequestPost({
|
|
438
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/membersManage",
|
|
439
|
+
"form": {
|
|
440
|
+
"sessionID": this.getSessionID(),
|
|
441
|
+
"action": "kick",
|
|
442
|
+
"memberId": steamID.getSteamID64(),
|
|
443
|
+
"queryString": ""
|
|
444
|
+
}
|
|
445
|
+
}, function(err, response, body) {
|
|
446
|
+
if(!callback) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
callback(err || null);
|
|
451
|
+
}, "steamcommunity");
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
SteamCommunity.prototype.getGroupHistory = function(gid, page, callback) {
|
|
455
|
+
if(typeof gid === 'string') {
|
|
456
|
+
gid = new SteamID(gid);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if(typeof page === 'function') {
|
|
460
|
+
callback = page;
|
|
461
|
+
page = 1;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
var self = this;
|
|
465
|
+
this.httpRequest("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/history?p=" + page, function(err, response, body) {
|
|
466
|
+
if (err) {
|
|
467
|
+
callback(err);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
var $ = Cheerio.load(body);
|
|
472
|
+
var output = {};
|
|
473
|
+
|
|
474
|
+
var paging = $('.group_paging p').text();
|
|
475
|
+
var match = paging.match(/(\d+) - (\d+) of (\d+)/);
|
|
476
|
+
|
|
477
|
+
if(match) {
|
|
478
|
+
output.first = parseInt(match[1], 10);
|
|
479
|
+
output.last = parseInt(match[2], 10);
|
|
480
|
+
output.total = parseInt(match[3], 10);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
output.items = [];
|
|
484
|
+
var currentYear = (new Date()).getFullYear();
|
|
485
|
+
var lastDate = Date.now();
|
|
486
|
+
|
|
487
|
+
Array.prototype.forEach.call($('.historyItem, .historyItemb'), function(item) {
|
|
488
|
+
var data = {};
|
|
489
|
+
|
|
490
|
+
var $item = $(item);
|
|
491
|
+
data.type = $item.find('.historyShort').text().replace(/ /g, '');
|
|
492
|
+
|
|
493
|
+
var users = $item.find('.whiteLink[data-miniprofile]');
|
|
494
|
+
var sid;
|
|
495
|
+
if(users[0]) {
|
|
496
|
+
sid = new SteamID();
|
|
497
|
+
sid.universe = SteamID.Universe.PUBLIC;
|
|
498
|
+
sid.type = SteamID.Type.INDIVIDUAL;
|
|
499
|
+
sid.instance = SteamID.Instance.DESKTOP;
|
|
500
|
+
sid.accountid = $(users[0]).data('miniprofile');
|
|
501
|
+
data.user = sid;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if(users[1]) {
|
|
505
|
+
sid = new SteamID();
|
|
506
|
+
sid.universe = SteamID.Universe.PUBLIC;
|
|
507
|
+
sid.type = SteamID.Type.INDIVIDUAL;
|
|
508
|
+
sid.instance = SteamID.Instance.DESKTOP;
|
|
509
|
+
sid.accountid = $(users[1]).data('miniprofile');
|
|
510
|
+
data.actor = sid;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// Figure out the date. Of course there's no year, because Valve
|
|
514
|
+
var dateParts = $item.find('.historyDate').text().split('@');
|
|
515
|
+
var date = dateParts[0].trim().replace(/(st|nd|th)$/, '').trim() + ', ' + currentYear;
|
|
516
|
+
var time = dateParts[1].trim().replace(/(am|pm)/, ' $1');
|
|
517
|
+
|
|
518
|
+
date = new Date(date + ' ' + time + ' UTC');
|
|
519
|
+
|
|
520
|
+
// If this date is in the future, or it's later than the previous one, decrement the year
|
|
521
|
+
if(date.getTime() > lastDate) {
|
|
522
|
+
date.setFullYear(date.getFullYear() - 1);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
data.date = date;
|
|
526
|
+
|
|
527
|
+
output.items.push(data);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
callback(null, output);
|
|
531
|
+
}, "steamcommunity");
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
SteamCommunity.prototype.getAllGroupComments = function(gid, from, count, callback) {
|
|
535
|
+
if (typeof gid === 'string') {
|
|
536
|
+
gid = new SteamID(gid);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
var options = {
|
|
540
|
+
"uri": "https://steamcommunity.com/comment/Clan/render/" + gid.getSteamID64() + "/-1/",
|
|
541
|
+
"form": {
|
|
542
|
+
"start": from,
|
|
543
|
+
"count": count
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
var self = this;
|
|
548
|
+
this.httpRequestPost(options, function(err, response, body) {
|
|
549
|
+
if (err) {
|
|
550
|
+
callback(err);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
var comments = [];
|
|
555
|
+
|
|
556
|
+
var $ = Cheerio.load(JSON.parse(body).comments_html);
|
|
557
|
+
|
|
558
|
+
$(".commentthread_comment_content").each(function () {
|
|
559
|
+
var comment = {};
|
|
560
|
+
var cachedSelector;
|
|
561
|
+
|
|
562
|
+
var $selector = $(this).find(".commentthread_author_link");
|
|
563
|
+
comment.authorName = $($selector).find("bdi").text();
|
|
564
|
+
comment.authorId = $($selector).attr("href").replace(/https?:\/\/steamcommunity.com\/(id|profiles)\//, "");
|
|
565
|
+
comment.date = Helpers.decodeSteamTime($(this).find(".commentthread_comment_timestamp").text().trim());
|
|
566
|
+
|
|
567
|
+
$selector = $(this).find(".commentthread_comment_text");
|
|
568
|
+
comment.commentId = $($selector).attr("id").replace("comment_content_", "");
|
|
569
|
+
comment.text = $($selector).html().trim();
|
|
570
|
+
|
|
571
|
+
comments.push(comment);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
callback(null, comments);
|
|
575
|
+
}, "steamcommunity");
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
SteamCommunity.prototype.deleteGroupComment = function(gid, cid, callback) {
|
|
579
|
+
if (typeof gid === 'string') {
|
|
580
|
+
gid = new SteamID(gid);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
if (typeof cid !== 'string') {
|
|
584
|
+
cid = cid.toString();
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
var options = {
|
|
588
|
+
"uri": "https://steamcommunity.com/comment/Clan/delete/" + gid.getSteamID64() + "/-1/",
|
|
589
|
+
"form": {
|
|
590
|
+
"sessionid": this.getSessionID(),
|
|
591
|
+
"gidcomment": cid
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
var self = this;
|
|
596
|
+
this.httpRequestPost(options, function(err, response, body) {
|
|
597
|
+
if(!callback) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
callback(err || null);
|
|
602
|
+
}, "steamcommunity");
|
|
603
|
+
};
|
|
604
|
+
|
|
605
|
+
SteamCommunity.prototype.postGroupComment = function(gid, message, callback) {
|
|
606
|
+
if (typeof gid === 'string') {
|
|
607
|
+
gid = new SteamID(gid);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
var options = {
|
|
611
|
+
"uri": "https://steamcommunity.com/comment/Clan/post/" + gid.getSteamID64() + "/-1/",
|
|
612
|
+
"form": {
|
|
613
|
+
"comment": message,
|
|
614
|
+
"count": 6,
|
|
615
|
+
"sessionid": this.getSessionID()
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
|
|
619
|
+
var self = this;
|
|
620
|
+
this.httpRequestPost(options, function(err, response, body) {
|
|
621
|
+
if(!callback) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
callback(err || null);
|
|
626
|
+
}, "steamcommunity");
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Get requests to join a restricted group.
|
|
631
|
+
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
632
|
+
* @param {function} callback - First argument is null/Error, second is array of SteamID objects
|
|
633
|
+
*/
|
|
634
|
+
SteamCommunity.prototype.getGroupJoinRequests = function(gid, callback) {
|
|
635
|
+
if (typeof gid === 'string') {
|
|
636
|
+
gid = new SteamID(gid);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
this.httpRequestGet("https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage", (err, res, body) => {
|
|
640
|
+
if (!body) {
|
|
641
|
+
callback(new Error("Malformed response"));
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
var matches = body.match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/g);
|
|
646
|
+
if (!matches) {
|
|
647
|
+
// no pending requests
|
|
648
|
+
callback(null, []);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
var requests = [];
|
|
653
|
+
for (var i = 0; i < matches.length; i++) {
|
|
654
|
+
requests.push(new SteamID("[U:1:" + matches[i].match(/JoinRequests_ApproveDenyUser\(\W*['"](\d+)['"],\W0\W\)/)[1] + "]"));
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
callback(null, requests);
|
|
658
|
+
}, "steamcommunity");
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Respond to one or more join requests to a restricted group.
|
|
663
|
+
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
664
|
+
* @param {SteamID|string|SteamID[]|string[]} steamIDs - The SteamIDs of the users you want to approve or deny membership for (or a single value)
|
|
665
|
+
* @param {boolean} approve - True to put them in the group, false to deny their membership
|
|
666
|
+
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
667
|
+
*/
|
|
668
|
+
SteamCommunity.prototype.respondToGroupJoinRequests = function(gid, steamIDs, approve, callback) {
|
|
669
|
+
if (typeof gid === 'string') {
|
|
670
|
+
gid = new SteamID(gid);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
var rgAccounts = (!Array.isArray(steamIDs) ? [steamIDs] : steamIDs).map(sid => sid.toString());
|
|
674
|
+
|
|
675
|
+
this.httpRequestPost({
|
|
676
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
|
677
|
+
"form": {
|
|
678
|
+
"rgAccounts": rgAccounts,
|
|
679
|
+
"bapprove": approve ? "1" : "0",
|
|
680
|
+
"json": "1",
|
|
681
|
+
"sessionID": this.getSessionID()
|
|
682
|
+
},
|
|
683
|
+
"json": true
|
|
684
|
+
}, (err, res, body) => {
|
|
685
|
+
if (!callback) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
if (body != EResult.OK) {
|
|
690
|
+
var err = new Error(EResult[body] || ("Error " + body));
|
|
691
|
+
err.eresult = body;
|
|
692
|
+
callback(err);
|
|
693
|
+
} else {
|
|
694
|
+
callback(null);
|
|
695
|
+
}
|
|
696
|
+
}, "steamcommunity");
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Respond to *ALL* pending group-join requests for a particular group.
|
|
701
|
+
* @param {SteamID|string} gid - The SteamID of the group you want to manage
|
|
702
|
+
* @param {boolean} approve - True to allow everyone who requested into the group, false to not
|
|
703
|
+
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
704
|
+
*/
|
|
705
|
+
SteamCommunity.prototype.respondToAllGroupJoinRequests = function(gid, approve, callback) {
|
|
706
|
+
if (typeof gid === 'string') {
|
|
707
|
+
gid = new SteamID(gid);
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
this.httpRequestPost({
|
|
711
|
+
"uri": "https://steamcommunity.com/gid/" + gid.getSteamID64() + "/joinRequestsManage",
|
|
712
|
+
"form": {
|
|
713
|
+
"bapprove": approve ? "1" : "0",
|
|
714
|
+
"json": "1",
|
|
715
|
+
"action": "bulkrespond",
|
|
716
|
+
"sessionID": this.getSessionID()
|
|
717
|
+
},
|
|
718
|
+
"json": true
|
|
719
|
+
}, (err, res, body) => {
|
|
720
|
+
if (!callback) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
if (body != EResult.OK) {
|
|
725
|
+
var err = new Error(EResult[body] || ("Error " + body));
|
|
726
|
+
err.eresult = body;
|
|
727
|
+
callback(err);
|
|
728
|
+
} else {
|
|
729
|
+
callback(null);
|
|
730
|
+
}
|
|
731
|
+
}, "steamcommunity");
|
|
732
|
+
};
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Follows a curator page
|
|
736
|
+
* @param {string|number} curatorId - ID of the curator (not a SteamID)
|
|
737
|
+
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
738
|
+
*/
|
|
739
|
+
SteamCommunity.prototype.followCurator = function(curatorId, callback) {
|
|
740
|
+
this.httpRequestPost({
|
|
741
|
+
"uri": "https://store.steampowered.com/curators/ajaxfollow",
|
|
742
|
+
"form": {
|
|
743
|
+
"clanid": curatorId,
|
|
744
|
+
"sessionid": this.getSessionID(),
|
|
745
|
+
"follow": 1
|
|
746
|
+
},
|
|
747
|
+
"json": true
|
|
748
|
+
}, (err, res, body) => {
|
|
749
|
+
if (!callback) {
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (err) {
|
|
754
|
+
callback(err);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
if (body.success && body.success.success != SteamCommunity.EResult.OK) {
|
|
759
|
+
callback(Helpers.eresultError(body.success.success));
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
callback(null);
|
|
764
|
+
}, "steamcommunity");
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Unfollows a curator page
|
|
769
|
+
* @param {string|number} curatorId - ID of the curator (not a SteamID)
|
|
770
|
+
* @param {function} callback - Takes only an Error object/null as the first argument
|
|
771
|
+
*/
|
|
772
|
+
SteamCommunity.prototype.unfollowCurator = function(curatorId, callback) {
|
|
773
|
+
this.httpRequestPost({
|
|
774
|
+
"uri": "https://store.steampowered.com/curators/ajaxfollow",
|
|
775
|
+
"form": {
|
|
776
|
+
"clanid": curatorId,
|
|
777
|
+
"sessionid": this.getSessionID(),
|
|
778
|
+
"follow": 0
|
|
779
|
+
},
|
|
780
|
+
"json": true
|
|
781
|
+
}, (err, res, body) => {
|
|
782
|
+
if (!callback) {
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
if (err) {
|
|
787
|
+
callback(err);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
if (body.success && body.success.success != SteamCommunity.EResult.OK) {
|
|
792
|
+
callback(Helpers.eresultError(body.success.success));
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
callback(null);
|
|
797
|
+
}, "steamcommunity");
|
|
798
|
+
};
|