steamcommunity 3.43.1 → 3.44.2

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.
@@ -1,475 +1,475 @@
1
- const Cheerio = require('cheerio');
2
- const FS = require('fs');
3
- const SteamID = require('steamid');
4
-
5
- const Helpers = require('./helpers.js');
6
- const SteamCommunity = require('../index.js');
7
-
8
- SteamCommunity.PrivacyState = {
9
- "Private": 1,
10
- "FriendsOnly": 2,
11
- "Public": 3
12
- };
13
-
14
- var CommentPrivacyState = {
15
- "1": 2, // private
16
- "2": 0, // friends only
17
- "3": 1 // anyone
18
- };
19
-
20
- SteamCommunity.prototype.setupProfile = function(callback) {
21
- var self = this;
22
- this._myProfile("edit?welcomed=1", null, function(err, response, body) {
23
- if(!callback) {
24
- return;
25
- }
26
-
27
- if(err || response.statusCode != 200) {
28
- callback(err || new Error("HTTP error " + response.statusCode));
29
- } else {
30
- callback(null);
31
- }
32
- });
33
- };
34
-
35
- SteamCommunity.prototype.editProfile = function(settings, callback) {
36
- var self = this;
37
- this._myProfile('edit/info', null, function(err, response, body) {
38
- if (err || response.statusCode != 200) {
39
- if (callback) {
40
- callback(err || new Error('HTTP error ' + response.statusCode));
41
- }
42
-
43
- return;
44
- }
45
-
46
- var $ = Cheerio.load(body);
47
- var existingSettings = $('#profile_edit_config').data('profile-edit');
48
- if (!existingSettings || !existingSettings.strPersonaName) {
49
- if (callback) {
50
- callback(new Error('Malformed response'));
51
- }
52
-
53
- return;
54
- }
55
-
56
- var values = {
57
- sessionID: self.getSessionID(),
58
- type: 'profileSave',
59
- weblink_1_title: '',
60
- weblink_1_url: '',
61
- weblink_2_title: '',
62
- weblink_2_url: '',
63
- weblink_3_title: '',
64
- weblink_3_url: '',
65
- personaName: existingSettings.strPersonaName,
66
- real_name: existingSettings.strRealName,
67
- summary: existingSettings.strSummary,
68
- country: existingSettings.LocationData.locCountryCode,
69
- state: existingSettings.LocationData.locStateCode,
70
- city: existingSettings.LocationData.locCityCode,
71
- customURL: existingSettings.strCustomURL,
72
- json: 1
73
- };
74
-
75
- for (var i in settings) {
76
- if(!settings.hasOwnProperty(i)) {
77
- continue;
78
- }
79
-
80
- switch(i) {
81
- case 'name':
82
- values.personaName = settings[i];
83
- break;
84
-
85
- case 'realName':
86
- values.real_name = settings[i];
87
- break;
88
-
89
- case 'summary':
90
- values.summary = settings[i];
91
- break;
92
-
93
- case 'country':
94
- values.country = settings[i];
95
- break;
96
-
97
- case 'state':
98
- values.state = settings[i];
99
- break;
100
-
101
- case 'city':
102
- values.city = settings[i];
103
- break;
104
-
105
- case 'customURL':
106
- values.customURL = settings[i];
107
- break;
108
-
109
- // These don't work right now
110
- /*
111
- case 'background':
112
- // The assetid of our desired profile background
113
- values.profile_background = settings[i];
114
- break;
115
-
116
- case 'featuredBadge':
117
- // Currently, game badges aren't supported
118
- values.favorite_badge_badgeid = settings[i];
119
- break;
120
-
121
- case 'primaryGroup':
122
- if(typeof settings[i] === 'object' && settings[i].getSteamID64) {
123
- values.primary_group_steamid = settings[i].getSteamID64();
124
- } else {
125
- values.primary_group_steamid = new SteamID(settings[i]).getSteamID64();
126
- }
127
-
128
- break;
129
- */
130
- // TODO: profile showcases
131
- }
132
- }
133
-
134
- self._myProfile('edit', values, function(err, response, body) {
135
- if (settings.customURL) {
136
- delete self._profileURL;
137
- }
138
-
139
- if (!callback) {
140
- return;
141
- }
142
-
143
- if (err || response.statusCode != 200) {
144
- callback(err || new Error('HTTP error ' + response.statusCode));
145
- return;
146
- }
147
-
148
- try {
149
- var json = JSON.parse(body);
150
- if (!json.success || json.success != 1) {
151
- callback(new Error(json.errmsg || 'Request was not successful'));
152
- return;
153
- }
154
-
155
- callback(null);
156
- } catch (ex) {
157
- callback(ex);
158
- }
159
- });
160
- });
161
- };
162
-
163
- SteamCommunity.prototype.profileSettings = function(settings, callback) {
164
- this._myProfile('edit/settings', null, (err, response, body) => {
165
- if (err || response.statusCode != 200) {
166
- if (callback) {
167
- callback(err || new Error('HTTP error ' + response.statusCode));
168
- }
169
-
170
- return;
171
- }
172
-
173
- var $ = Cheerio.load(body);
174
- var existingSettings = $('#profile_edit_config').data('profile-edit');
175
- if (!existingSettings || !existingSettings.Privacy) {
176
- if (callback) {
177
- callback(new Error('Malformed response'));
178
- }
179
-
180
- return;
181
- }
182
-
183
- // PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
184
- // eCommentPermission
185
- var privacy = existingSettings.Privacy.PrivacySettings;
186
- var commentPermission = existingSettings.Privacy.eCommentPermission;
187
-
188
- for (var i in settings) {
189
- if (!settings.hasOwnProperty(i)) {
190
- continue;
191
- }
192
-
193
- switch (i) {
194
- case 'profile':
195
- privacy.PrivacyProfile = settings[i];
196
- break;
197
-
198
- case 'comments':
199
- commentPermission = CommentPrivacyState[settings[i]];
200
- break;
201
-
202
- case 'inventory':
203
- privacy.PrivacyInventory = settings[i];
204
- break;
205
-
206
- case 'inventoryGifts':
207
- privacy.PrivacyInventoryGifts = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
208
- break;
209
-
210
- case 'gameDetails':
211
- privacy.PrivacyOwnedGames = settings[i];
212
- break;
213
-
214
- case 'playtime':
215
- privacy.PrivacyPlaytime = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
216
- break;
217
-
218
- case 'friendsList':
219
- privacy.PrivacyFriendsList = settings[i];
220
- break;
221
- }
222
- }
223
-
224
- this._myProfile({
225
- method: 'POST',
226
- endpoint: 'ajaxsetprivacy/',
227
- json: true,
228
- formData: { // it's multipart because lolvalve
229
- sessionid: this.getSessionID(),
230
- Privacy: JSON.stringify(privacy),
231
- eCommentPermission: commentPermission
232
- }
233
- }, null, function(err, response, body) {
234
- if (err || response.statusCode != 200) {
235
- if (callback) {
236
- callback(err || new Error('HTTP error ' + response.statusCode));
237
- }
238
-
239
- return;
240
- }
241
-
242
- if (body.success != 1) {
243
- if (callback) {
244
- callback(new Error(body.success ? 'Error ' + body.success : 'Request was not successful'));
245
- }
246
-
247
- return;
248
- }
249
-
250
- if (callback) {
251
- callback(null, body.Privacy);
252
- }
253
- });
254
- });
255
- };
256
-
257
- SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
258
- if(typeof format === 'function') {
259
- callback = format;
260
- format = null;
261
- }
262
-
263
- // are we logged in?
264
- if (!this.steamID) {
265
- callback(new Error("Not Logged In"));
266
- return;
267
- }
268
-
269
- var self = this;
270
-
271
- if(image instanceof Buffer) {
272
- doUpload(image);
273
- } else if(image.match(/^https?:\/\//)) {
274
- this.httpRequestGet({
275
- "uri": image,
276
- "encoding": null
277
- }, function(err, response, body) {
278
- if(err || response.statusCode != 200) {
279
- if(callback) {
280
- callback(err ? new Error(err.message + " downloading image") : new Error("HTTP error " + response.statusCode + " downloading image"));
281
- }
282
-
283
- return;
284
- }
285
-
286
- if(!format) {
287
- format = response.headers['content-type'];
288
- }
289
-
290
- doUpload(body);
291
- }, "steamcommunity");
292
- } else {
293
- if(!format) {
294
- format = image.match(/\.([^\.]+)$/);
295
- if(format) {
296
- format = format[1];
297
- }
298
- }
299
-
300
- FS.readFile(image, function(err, file) {
301
- if(err) {
302
- if(callback) {
303
- callback(err);
304
- }
305
-
306
- return;
307
- }
308
-
309
- doUpload(file);
310
- })
311
- }
312
-
313
- function doUpload(buffer) {
314
- if(!format) {
315
- if(callback) {
316
- callback(new Error("Unknown image format"));
317
- }
318
-
319
- return;
320
- }
321
-
322
- if(format.match(/^image\//)) {
323
- format = format.substring(6);
324
- }
325
-
326
- var filename = '';
327
- var contentType = '';
328
-
329
- switch(format.toLowerCase()) {
330
- case 'jpg':
331
- case 'jpeg':
332
- filename = 'avatar.jpg';
333
- contentType = 'image/jpeg';
334
- break;
335
-
336
- case 'png':
337
- filename = 'avatar.png';
338
- contentType = 'image/png';
339
- break;
340
-
341
- case 'gif':
342
- filename = 'avatar.gif';
343
- contentType = 'image/gif';
344
- break;
345
-
346
- default:
347
- if(callback) {
348
- callback(new Error("Unknown or invalid image format"));
349
- }
350
-
351
- return;
352
- }
353
-
354
- self.httpRequestPost({
355
- "uri": "https://steamcommunity.com/actions/FileUploader",
356
- "formData": {
357
- "MAX_FILE_SIZE": buffer.length,
358
- "type": "player_avatar_image",
359
- "sId": self.steamID.getSteamID64(),
360
- "sessionid": self.getSessionID(),
361
- "doSub": 1,
362
- "json": 1,
363
- "avatar": {
364
- "value": buffer,
365
- "options": {
366
- "filename": filename,
367
- "contentType": contentType
368
- }
369
- }
370
- },
371
- "json": true
372
- }, function(err, response, body) {
373
- if(err) {
374
- if(callback) {
375
- callback(err);
376
- }
377
-
378
- return;
379
- }
380
-
381
- if(body && !body.success && body.message) {
382
- if(callback) {
383
- callback(new Error(body.message));
384
- }
385
-
386
- return;
387
- }
388
-
389
- if(response.statusCode != 200) {
390
- if(callback) {
391
- callback(new Error("HTTP error " + response.statusCode));
392
- }
393
-
394
- return;
395
- }
396
-
397
- if(!body || !body.success) {
398
- if(callback) {
399
- callback(new Error("Malformed response"));
400
- }
401
-
402
- return;
403
- }
404
-
405
- if(callback) {
406
- callback(null, body.images.full);
407
- }
408
- }, "steamcommunity");
409
- }
410
- };
411
-
412
- /**
413
- * Post a new status to your profile activity feed.
414
- * @param {string} statusText - The text of this status update
415
- * @param {{appID: int}} [options] - Options for this status update. All are optional. If you don't pass any options, this can be omitted.
416
- * @param {function} callback - err, postID
417
- */
418
- SteamCommunity.prototype.postProfileStatus = function(statusText, options, callback) {
419
- if (typeof options === 'function') {
420
- callback = options;
421
- options = {};
422
- }
423
-
424
- this._myProfile("ajaxpostuserstatus/", {
425
- "appid": options.appID || 0,
426
- "sessionid": this.getSessionID(),
427
- "status_text": statusText
428
- }, (err, res, body) => {
429
- try {
430
- body = JSON.parse(body);
431
- if (body.message) {
432
- callback(new Error(body.message));
433
- return;
434
- }
435
-
436
- var match = body.blotter_html.match(/id="userstatus_(\d+)_/);
437
- if (!match) {
438
- callback(new Error("Malformed response"));
439
- return;
440
- }
441
-
442
- callback(null, parseInt(match[1], 10));
443
- } catch (ex) {
444
- callback(ex);
445
- }
446
- });
447
- };
448
-
449
- /**
450
- * Delete a previously-posted profile status update.
451
- * @param {int} postID
452
- * @param {function} [callback]
453
- */
454
- SteamCommunity.prototype.deleteProfileStatus = function(postID, callback) {
455
- this._myProfile("ajaxdeleteuserstatus/", {
456
- "sessionid": this.getSessionID(),
457
- "postid": postID
458
- }, (err, res, body) => {
459
- if (!callback) {
460
- return;
461
- }
462
-
463
- try {
464
- body = JSON.parse(body);
465
- if (!body.success) {
466
- callback(new Error("Malformed response"));
467
- return;
468
- }
469
-
470
- callback(Helpers.eresultError(body.success));
471
- } catch (ex) {
472
- callback(ex);
473
- }
474
- });
475
- };
1
+ const Cheerio = require('cheerio');
2
+ const FS = require('fs');
3
+ const SteamID = require('steamid');
4
+
5
+ const Helpers = require('./helpers.js');
6
+ const SteamCommunity = require('../index.js');
7
+
8
+ SteamCommunity.PrivacyState = {
9
+ "Private": 1,
10
+ "FriendsOnly": 2,
11
+ "Public": 3
12
+ };
13
+
14
+ var CommentPrivacyState = {
15
+ "1": 2, // private
16
+ "2": 0, // friends only
17
+ "3": 1 // anyone
18
+ };
19
+
20
+ SteamCommunity.prototype.setupProfile = function(callback) {
21
+ var self = this;
22
+ this._myProfile("edit?welcomed=1", null, function(err, response, body) {
23
+ if(!callback) {
24
+ return;
25
+ }
26
+
27
+ if(err || response.statusCode != 200) {
28
+ callback(err || new Error("HTTP error " + response.statusCode));
29
+ } else {
30
+ callback(null);
31
+ }
32
+ });
33
+ };
34
+
35
+ SteamCommunity.prototype.editProfile = function(settings, callback) {
36
+ var self = this;
37
+ this._myProfile('edit/info', null, function(err, response, body) {
38
+ if (err || response.statusCode != 200) {
39
+ if (callback) {
40
+ callback(err || new Error('HTTP error ' + response.statusCode));
41
+ }
42
+
43
+ return;
44
+ }
45
+
46
+ var $ = Cheerio.load(body);
47
+ var existingSettings = $('#profile_edit_config').data('profile-edit');
48
+ if (!existingSettings || !existingSettings.strPersonaName) {
49
+ if (callback) {
50
+ callback(new Error('Malformed response'));
51
+ }
52
+
53
+ return;
54
+ }
55
+
56
+ var values = {
57
+ sessionID: self.getSessionID(),
58
+ type: 'profileSave',
59
+ weblink_1_title: '',
60
+ weblink_1_url: '',
61
+ weblink_2_title: '',
62
+ weblink_2_url: '',
63
+ weblink_3_title: '',
64
+ weblink_3_url: '',
65
+ personaName: existingSettings.strPersonaName,
66
+ real_name: existingSettings.strRealName,
67
+ summary: existingSettings.strSummary,
68
+ country: existingSettings.LocationData.locCountryCode,
69
+ state: existingSettings.LocationData.locStateCode,
70
+ city: existingSettings.LocationData.locCityCode,
71
+ customURL: existingSettings.strCustomURL,
72
+ json: 1
73
+ };
74
+
75
+ for (var i in settings) {
76
+ if(!settings.hasOwnProperty(i)) {
77
+ continue;
78
+ }
79
+
80
+ switch(i) {
81
+ case 'name':
82
+ values.personaName = settings[i];
83
+ break;
84
+
85
+ case 'realName':
86
+ values.real_name = settings[i];
87
+ break;
88
+
89
+ case 'summary':
90
+ values.summary = settings[i];
91
+ break;
92
+
93
+ case 'country':
94
+ values.country = settings[i];
95
+ break;
96
+
97
+ case 'state':
98
+ values.state = settings[i];
99
+ break;
100
+
101
+ case 'city':
102
+ values.city = settings[i];
103
+ break;
104
+
105
+ case 'customURL':
106
+ values.customURL = settings[i];
107
+ break;
108
+
109
+ // These don't work right now
110
+ /*
111
+ case 'background':
112
+ // The assetid of our desired profile background
113
+ values.profile_background = settings[i];
114
+ break;
115
+
116
+ case 'featuredBadge':
117
+ // Currently, game badges aren't supported
118
+ values.favorite_badge_badgeid = settings[i];
119
+ break;
120
+
121
+ case 'primaryGroup':
122
+ if(typeof settings[i] === 'object' && settings[i].getSteamID64) {
123
+ values.primary_group_steamid = settings[i].getSteamID64();
124
+ } else {
125
+ values.primary_group_steamid = new SteamID(settings[i]).getSteamID64();
126
+ }
127
+
128
+ break;
129
+ */
130
+ // TODO: profile showcases
131
+ }
132
+ }
133
+
134
+ self._myProfile('edit', values, function(err, response, body) {
135
+ if (settings.customURL) {
136
+ delete self._profileURL;
137
+ }
138
+
139
+ if (!callback) {
140
+ return;
141
+ }
142
+
143
+ if (err || response.statusCode != 200) {
144
+ callback(err || new Error('HTTP error ' + response.statusCode));
145
+ return;
146
+ }
147
+
148
+ try {
149
+ var json = JSON.parse(body);
150
+ if (!json.success || json.success != 1) {
151
+ callback(new Error(json.errmsg || 'Request was not successful'));
152
+ return;
153
+ }
154
+
155
+ callback(null);
156
+ } catch (ex) {
157
+ callback(ex);
158
+ }
159
+ });
160
+ });
161
+ };
162
+
163
+ SteamCommunity.prototype.profileSettings = function(settings, callback) {
164
+ this._myProfile('edit/settings', null, (err, response, body) => {
165
+ if (err || response.statusCode != 200) {
166
+ if (callback) {
167
+ callback(err || new Error('HTTP error ' + response.statusCode));
168
+ }
169
+
170
+ return;
171
+ }
172
+
173
+ var $ = Cheerio.load(body);
174
+ var existingSettings = $('#profile_edit_config').data('profile-edit');
175
+ if (!existingSettings || !existingSettings.Privacy) {
176
+ if (callback) {
177
+ callback(new Error('Malformed response'));
178
+ }
179
+
180
+ return;
181
+ }
182
+
183
+ // PrivacySettings => {PrivacyProfile, PrivacyInventory, PrivacyInventoryGifts, PrivacyOwnedGames, PrivacyPlaytime}
184
+ // eCommentPermission
185
+ var privacy = existingSettings.Privacy.PrivacySettings;
186
+ var commentPermission = existingSettings.Privacy.eCommentPermission;
187
+
188
+ for (var i in settings) {
189
+ if (!settings.hasOwnProperty(i)) {
190
+ continue;
191
+ }
192
+
193
+ switch (i) {
194
+ case 'profile':
195
+ privacy.PrivacyProfile = settings[i];
196
+ break;
197
+
198
+ case 'comments':
199
+ commentPermission = CommentPrivacyState[settings[i]];
200
+ break;
201
+
202
+ case 'inventory':
203
+ privacy.PrivacyInventory = settings[i];
204
+ break;
205
+
206
+ case 'inventoryGifts':
207
+ privacy.PrivacyInventoryGifts = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
208
+ break;
209
+
210
+ case 'gameDetails':
211
+ privacy.PrivacyOwnedGames = settings[i];
212
+ break;
213
+
214
+ case 'playtime':
215
+ privacy.PrivacyPlaytime = settings[i] ? SteamCommunity.PrivacyState.Private : SteamCommunity.PrivacyState.Public;
216
+ break;
217
+
218
+ case 'friendsList':
219
+ privacy.PrivacyFriendsList = settings[i];
220
+ break;
221
+ }
222
+ }
223
+
224
+ this._myProfile({
225
+ method: 'POST',
226
+ endpoint: 'ajaxsetprivacy/',
227
+ json: true,
228
+ formData: { // it's multipart because lolvalve
229
+ sessionid: this.getSessionID(),
230
+ Privacy: JSON.stringify(privacy),
231
+ eCommentPermission: commentPermission
232
+ }
233
+ }, null, function(err, response, body) {
234
+ if (err || response.statusCode != 200) {
235
+ if (callback) {
236
+ callback(err || new Error('HTTP error ' + response.statusCode));
237
+ }
238
+
239
+ return;
240
+ }
241
+
242
+ if (body.success != 1) {
243
+ if (callback) {
244
+ callback(new Error(body.success ? 'Error ' + body.success : 'Request was not successful'));
245
+ }
246
+
247
+ return;
248
+ }
249
+
250
+ if (callback) {
251
+ callback(null, body.Privacy);
252
+ }
253
+ });
254
+ });
255
+ };
256
+
257
+ SteamCommunity.prototype.uploadAvatar = function(image, format, callback) {
258
+ if(typeof format === 'function') {
259
+ callback = format;
260
+ format = null;
261
+ }
262
+
263
+ // are we logged in?
264
+ if (!this.steamID) {
265
+ callback(new Error("Not Logged In"));
266
+ return;
267
+ }
268
+
269
+ var self = this;
270
+
271
+ if(image instanceof Buffer) {
272
+ doUpload(image);
273
+ } else if(image.match(/^https?:\/\//)) {
274
+ this.httpRequestGet({
275
+ "uri": image,
276
+ "encoding": null
277
+ }, function(err, response, body) {
278
+ if(err || response.statusCode != 200) {
279
+ if(callback) {
280
+ callback(err ? new Error(err.message + " downloading image") : new Error("HTTP error " + response.statusCode + " downloading image"));
281
+ }
282
+
283
+ return;
284
+ }
285
+
286
+ if(!format) {
287
+ format = response.headers['content-type'];
288
+ }
289
+
290
+ doUpload(body);
291
+ }, "steamcommunity");
292
+ } else {
293
+ if(!format) {
294
+ format = image.match(/\.([^\.]+)$/);
295
+ if(format) {
296
+ format = format[1];
297
+ }
298
+ }
299
+
300
+ FS.readFile(image, function(err, file) {
301
+ if(err) {
302
+ if(callback) {
303
+ callback(err);
304
+ }
305
+
306
+ return;
307
+ }
308
+
309
+ doUpload(file);
310
+ })
311
+ }
312
+
313
+ function doUpload(buffer) {
314
+ if(!format) {
315
+ if(callback) {
316
+ callback(new Error("Unknown image format"));
317
+ }
318
+
319
+ return;
320
+ }
321
+
322
+ if(format.match(/^image\//)) {
323
+ format = format.substring(6);
324
+ }
325
+
326
+ var filename = '';
327
+ var contentType = '';
328
+
329
+ switch(format.toLowerCase()) {
330
+ case 'jpg':
331
+ case 'jpeg':
332
+ filename = 'avatar.jpg';
333
+ contentType = 'image/jpeg';
334
+ break;
335
+
336
+ case 'png':
337
+ filename = 'avatar.png';
338
+ contentType = 'image/png';
339
+ break;
340
+
341
+ case 'gif':
342
+ filename = 'avatar.gif';
343
+ contentType = 'image/gif';
344
+ break;
345
+
346
+ default:
347
+ if(callback) {
348
+ callback(new Error("Unknown or invalid image format"));
349
+ }
350
+
351
+ return;
352
+ }
353
+
354
+ self.httpRequestPost({
355
+ "uri": "https://steamcommunity.com/actions/FileUploader",
356
+ "formData": {
357
+ "MAX_FILE_SIZE": buffer.length,
358
+ "type": "player_avatar_image",
359
+ "sId": self.steamID.getSteamID64(),
360
+ "sessionid": self.getSessionID(),
361
+ "doSub": 1,
362
+ "json": 1,
363
+ "avatar": {
364
+ "value": buffer,
365
+ "options": {
366
+ "filename": filename,
367
+ "contentType": contentType
368
+ }
369
+ }
370
+ },
371
+ "json": true
372
+ }, function(err, response, body) {
373
+ if(err) {
374
+ if(callback) {
375
+ callback(err);
376
+ }
377
+
378
+ return;
379
+ }
380
+
381
+ if(body && !body.success && body.message) {
382
+ if(callback) {
383
+ callback(new Error(body.message));
384
+ }
385
+
386
+ return;
387
+ }
388
+
389
+ if(response.statusCode != 200) {
390
+ if(callback) {
391
+ callback(new Error("HTTP error " + response.statusCode));
392
+ }
393
+
394
+ return;
395
+ }
396
+
397
+ if(!body || !body.success) {
398
+ if(callback) {
399
+ callback(new Error("Malformed response"));
400
+ }
401
+
402
+ return;
403
+ }
404
+
405
+ if(callback) {
406
+ callback(null, body.images.full);
407
+ }
408
+ }, "steamcommunity");
409
+ }
410
+ };
411
+
412
+ /**
413
+ * Post a new status to your profile activity feed.
414
+ * @param {string} statusText - The text of this status update
415
+ * @param {{appID: int}} [options] - Options for this status update. All are optional. If you don't pass any options, this can be omitted.
416
+ * @param {function} callback - err, postID
417
+ */
418
+ SteamCommunity.prototype.postProfileStatus = function(statusText, options, callback) {
419
+ if (typeof options === 'function') {
420
+ callback = options;
421
+ options = {};
422
+ }
423
+
424
+ this._myProfile("ajaxpostuserstatus/", {
425
+ "appid": options.appID || 0,
426
+ "sessionid": this.getSessionID(),
427
+ "status_text": statusText
428
+ }, (err, res, body) => {
429
+ try {
430
+ body = JSON.parse(body);
431
+ if (body.message) {
432
+ callback(new Error(body.message));
433
+ return;
434
+ }
435
+
436
+ var match = body.blotter_html.match(/id="userstatus_(\d+)_/);
437
+ if (!match) {
438
+ callback(new Error("Malformed response"));
439
+ return;
440
+ }
441
+
442
+ callback(null, parseInt(match[1], 10));
443
+ } catch (ex) {
444
+ callback(ex);
445
+ }
446
+ });
447
+ };
448
+
449
+ /**
450
+ * Delete a previously-posted profile status update.
451
+ * @param {int} postID
452
+ * @param {function} [callback]
453
+ */
454
+ SteamCommunity.prototype.deleteProfileStatus = function(postID, callback) {
455
+ this._myProfile("ajaxdeleteuserstatus/", {
456
+ "sessionid": this.getSessionID(),
457
+ "postid": postID
458
+ }, (err, res, body) => {
459
+ if (!callback) {
460
+ return;
461
+ }
462
+
463
+ try {
464
+ body = JSON.parse(body);
465
+ if (!body.success) {
466
+ callback(new Error("Malformed response"));
467
+ return;
468
+ }
469
+
470
+ callback(Helpers.eresultError(body.success));
471
+ } catch (ex) {
472
+ callback(ex);
473
+ }
474
+ });
475
+ };