steamcommunity 3.46.1 → 3.47.0

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.
Files changed (44) hide show
  1. package/classes/CConfirmation.js +37 -37
  2. package/classes/CEconItem.js +120 -120
  3. package/classes/CMarketItem.js +189 -189
  4. package/classes/CMarketSearchResult.js +89 -89
  5. package/classes/CSteamGroup.js +155 -155
  6. package/classes/CSteamUser.js +225 -217
  7. package/components/chat.js +283 -283
  8. package/components/confirmations.js +428 -428
  9. package/components/groups.js +798 -732
  10. package/components/help.js +64 -64
  11. package/components/helpers.js +128 -108
  12. package/components/http.js +150 -150
  13. package/components/inventoryhistory.js +173 -173
  14. package/components/market.js +387 -387
  15. package/components/profile.js +475 -475
  16. package/components/twofactor.js +152 -152
  17. package/components/users.js +831 -767
  18. package/components/webapi.js +118 -118
  19. package/examples/edit-group-announcement.js +118 -118
  20. package/package.json +9 -2
  21. package/resources/EChatState.js +14 -14
  22. package/resources/EConfirmationType.js +12 -12
  23. package/resources/EFriendRelationship.js +23 -23
  24. package/resources/EPersonaState.js +23 -23
  25. package/resources/EPersonaStateFlag.js +32 -32
  26. package/resources/EResult.js +254 -254
  27. package/resources/ESharedFileType.js +13 -13
  28. package/.editorconfig +0 -13
  29. package/.github/FUNDING.yml +0 -2
  30. package/.idea/.name +0 -1
  31. package/.idea/codeStyleSettings.xml +0 -13
  32. package/.idea/codeStyles/Project.xml +0 -15
  33. package/.idea/codeStyles/codeStyleConfig.xml +0 -6
  34. package/.idea/copyright/profiles_settings.xml +0 -3
  35. package/.idea/encodings.xml +0 -6
  36. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  37. package/.idea/jsLibraryMappings.xml +0 -6
  38. package/.idea/misc.xml +0 -6
  39. package/.idea/modules.xml +0 -9
  40. package/.idea/node-steamcommunity.iml +0 -8
  41. package/.idea/steamcommunity.iml +0 -10
  42. package/.idea/vcs.xml +0 -7
  43. package/.idea/watcherTasks.xml +0 -4
  44. package/CONTRIBUTING.md +0 -36
@@ -1,217 +1,225 @@
1
- var SteamCommunity = require('../index.js');
2
- var Helpers = require('../components/helpers.js');
3
- var SteamID = require('steamid');
4
- var xml2js = require('xml2js');
5
-
6
- SteamCommunity.prototype.getSteamUser = function(id, callback) {
7
- if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
8
- throw new Error("id parameter should be a user URL string or a SteamID object");
9
- }
10
-
11
- if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.INDIVIDUAL)) {
12
- throw new Error("SteamID must stand for an individual account in the public universe");
13
- }
14
-
15
- var self = this;
16
- this.httpRequest("http://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
17
- if (err) {
18
- callback(err);
19
- return;
20
- }
21
-
22
- xml2js.parseString(body, function(err, result) {
23
- if(err || (!result.response && !result.profile)) {
24
- callback(err || new Error("No valid response"));
25
- return;
26
- }
27
-
28
- if(result.response && result.response.error && result.response.error.length) {
29
- callback(new Error(result.response.error[0]));
30
- return;
31
- }
32
-
33
- // Try and find custom URL from redirect
34
- var customurl = null;
35
- if(response.request.redirects && response.request.redirects.length) {
36
- var match = response.request.redirects[0].redirectUri.match(/https?:\/\/steamcommunity\.com\/id\/([^/])+\/\?xml=1/);
37
- if(match) {
38
- customurl = match[1];
39
- }
40
- }
41
-
42
- if(!result.profile.steamID64) {
43
- callback(new Error("No valid response"));
44
- return;
45
- }
46
-
47
- callback(null, new CSteamUser(self, result.profile, customurl));
48
- });
49
- }, "steamcommunity");
50
- };
51
-
52
- function CSteamUser(community, userData, customurl) {
53
- this._community = community;
54
-
55
- this.steamID = new SteamID(userData.steamID64[0]);
56
- this.name = processItem('steamID');
57
- this.onlineState = processItem('onlineState');
58
- this.stateMessage = processItem('stateMessage');
59
- this.privacyState = processItem('privacyState', 'uncreated');
60
- this.visibilityState = processItem('visibilityState');
61
- this.avatarHash = processItem('avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
62
- if(this.avatarHash) {
63
- this.avatarHash = this.avatarHash[1];
64
- }
65
-
66
- this.vacBanned = processItem('vacBanned', false) == 1;
67
- this.tradeBanState = processItem('tradeBanState', 'None');
68
- this.isLimitedAccount = processItem('isLimitedAccount') == 1;
69
- this.customURL = processItem('customURL', customurl);
70
-
71
- if(this.visibilityState == 3) {
72
- let memberSinceValue = processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1");
73
-
74
- if (memberSinceValue.indexOf(',') === -1) {
75
- memberSinceValue += ', ' + new Date().getFullYear();
76
- }
77
-
78
- this.memberSince = new Date(memberSinceValue);
79
- this.location = processItem('location');
80
- this.realName = processItem('realname');
81
- this.summary = processItem('summary');
82
- } else {
83
- this.memberSince = null;
84
- this.location = null;
85
- this.realName = null;
86
- this.summary = null;
87
- }
88
-
89
- // Maybe handle mostPlayedGames?
90
-
91
- this.groups = null;
92
- this.primaryGroup = null;
93
-
94
- var self = this;
95
- if(userData.groups && userData.groups[0] && userData.groups[0].group) {
96
- this.groups = userData.groups[0].group.map(function(group) {
97
- if(group['$'] && group['$'].isPrimary === "1") {
98
- self.primaryGroup = new SteamID(group.groupID64[0]);
99
- }
100
-
101
- return new SteamID(group.groupID64[0]);
102
- });
103
- }
104
-
105
- function processItem(name, defaultVal) {
106
- if(!userData[name]) {
107
- return defaultVal;
108
- }
109
-
110
- return userData[name][0];
111
- }
112
- }
113
-
114
- CSteamUser.getAvatarURL = function(hash, size, protocol) {
115
- size = size || '';
116
- protocol = protocol || 'http://';
117
-
118
- hash = hash || "72f78b4c8cc1f62323f8a33f6d53e27db57c2252"; // The default "?" avatar
119
-
120
- var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
121
- if(size == 'full' || size == 'medium') {
122
- return url + "_" + size + ".jpg";
123
- } else {
124
- return url + ".jpg";
125
- }
126
- };
127
-
128
- CSteamUser.prototype.getAvatarURL = function(size, protocol) {
129
- return CSteamUser.getAvatarURL(this.avatarHash, size, protocol);
130
- };
131
-
132
- CSteamUser.prototype.addFriend = function(callback) {
133
- this._community.addFriend(this.steamID, callback);
134
- };
135
-
136
- CSteamUser.prototype.acceptFriendRequest = function(callback) {
137
- this._community.acceptFriendRequest(this.steamID, callback);
138
- };
139
-
140
- CSteamUser.prototype.removeFriend = function(callback) {
141
- this._community.removeFriend(this.steamID, callback);
142
-
143
- };
144
-
145
- CSteamUser.prototype.blockCommunication = function(callback) {
146
- this._community.blockCommunication(this.steamID, callback);
147
- };
148
-
149
- CSteamUser.prototype.unblockCommunication = function(callback) {
150
- this._community.unblockCommunication(this.steamID, callback);
151
- };
152
-
153
- CSteamUser.prototype.comment = function(message, callback) {
154
- this._community.postUserComment(this.steamID, message, callback);
155
- };
156
-
157
- CSteamUser.prototype.deleteComment = function(commentID, callback) {
158
- this._community.deleteUserComment(this.steamID, commentID, callback);
159
- };
160
-
161
- CSteamUser.prototype.getComments = function(options, callback) {
162
- this._community.getUserComments(this.steamID, options, callback);
163
- };
164
-
165
- CSteamUser.prototype.inviteToGroup = function(groupID, callback) {
166
- this._community.inviteUserToGroup(this.steamID, groupID, callback);
167
- };
168
-
169
- CSteamUser.prototype.getAliases = function(callback) {
170
- this._community.getUserAliases(this.steamID, callback);
171
- };
172
-
173
- CSteamUser.prototype.getInventoryContexts = function(callback) {
174
- this._community.getUserInventoryContexts(this.steamID, callback);
175
- };
176
-
177
- /**
178
- * Get the contents of a user's inventory context.
179
- * @deprecated Use CSteamUser#getInventoryContents instead
180
- * @param {int} appID - The Steam application ID of the game for which you want an inventory
181
- * @param {int} contextID - The ID of the "context" within the game you want to retrieve
182
- * @param {boolean} tradableOnly - true to get only tradable items and currencies
183
- * @param callback
184
- */
185
- CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
186
- this._community.getUserInventory(this.steamID, appID, contextID, tradableOnly, callback);
187
- };
188
-
189
- /**
190
- * Get the contents of a user's inventory context.
191
- * @param {int} appID - The Steam application ID of the game for which you want an inventory
192
- * @param {int} contextID - The ID of the "context" within the game you want to retrieve
193
- * @param {boolean} tradableOnly - true to get only tradable items and currencies
194
- * @param {string} [language] - The language of item descriptions to return. Omit for default (which may either be English or your account's chosen language)
195
- * @param callback
196
- */
197
- CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, language, callback) {
198
- this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, language, callback);
199
- };
200
-
201
- /**
202
- * Get the background URL of user's profile.
203
- * @param {function} callback
204
- */
205
- CSteamUser.prototype.getProfileBackground = function(callback) {
206
- this._community.getUserProfileBackground(this.steamID, callback);
207
- };
208
-
209
- /**
210
- * Upload an image to Steam and send it to the target user over chat.
211
- * @param {Buffer} imageContentsBuffer - The image contents, as a Buffer
212
- * @param {{spoiler?: boolean}} [options]
213
- * @param {function} callback
214
- */
215
- CSteamUser.prototype.sendImage = function(imageContentsBuffer, options, callback) {
216
- this._community.sendImageToUser(this.steamID, imageContentsBuffer, options, callback);
217
- };
1
+ var SteamCommunity = require('../index.js');
2
+ var Helpers = require('../components/helpers.js');
3
+ var SteamID = require('steamid');
4
+ var xml2js = require('xml2js');
5
+
6
+ SteamCommunity.prototype.getSteamUser = function(id, callback) {
7
+ if(typeof id !== 'string' && !Helpers.isSteamID(id)) {
8
+ throw new Error("id parameter should be a user URL string or a SteamID object");
9
+ }
10
+
11
+ if(typeof id === 'object' && (id.universe != SteamID.Universe.PUBLIC || id.type != SteamID.Type.INDIVIDUAL)) {
12
+ throw new Error("SteamID must stand for an individual account in the public universe");
13
+ }
14
+
15
+ var self = this;
16
+ this.httpRequest("http://steamcommunity.com/" + (typeof id === 'string' ? "id/" + id : "profiles/" + id.toString()) + "/?xml=1", function(err, response, body) {
17
+ if (err) {
18
+ callback(err);
19
+ return;
20
+ }
21
+
22
+ xml2js.parseString(body, function(err, result) {
23
+ if(err || (!result.response && !result.profile)) {
24
+ callback(err || new Error("No valid response"));
25
+ return;
26
+ }
27
+
28
+ if(result.response && result.response.error && result.response.error.length) {
29
+ callback(new Error(result.response.error[0]));
30
+ return;
31
+ }
32
+
33
+ // Try and find custom URL from redirect
34
+ var customurl = null;
35
+ if(response.request.redirects && response.request.redirects.length) {
36
+ var match = response.request.redirects[0].redirectUri.match(/https?:\/\/steamcommunity\.com\/id\/([^/])+\/\?xml=1/);
37
+ if(match) {
38
+ customurl = match[1];
39
+ }
40
+ }
41
+
42
+ if(!result.profile.steamID64) {
43
+ callback(new Error("No valid response"));
44
+ return;
45
+ }
46
+
47
+ callback(null, new CSteamUser(self, result.profile, customurl));
48
+ });
49
+ }, "steamcommunity");
50
+ };
51
+
52
+ function CSteamUser(community, userData, customurl) {
53
+ this._community = community;
54
+
55
+ this.steamID = new SteamID(userData.steamID64[0]);
56
+ this.name = processItem('steamID');
57
+ this.onlineState = processItem('onlineState');
58
+ this.stateMessage = processItem('stateMessage');
59
+ this.privacyState = processItem('privacyState', 'uncreated');
60
+ this.visibilityState = processItem('visibilityState');
61
+ this.avatarHash = processItem('avatarIcon', '').match(/([0-9a-f]+)\.[a-z]+$/);
62
+ if(this.avatarHash) {
63
+ this.avatarHash = this.avatarHash[1];
64
+ }
65
+
66
+ this.vacBanned = processItem('vacBanned', false) == 1;
67
+ this.tradeBanState = processItem('tradeBanState', 'None');
68
+ this.isLimitedAccount = processItem('isLimitedAccount') == 1;
69
+ this.customURL = processItem('customURL', customurl);
70
+
71
+ if(this.visibilityState == 3) {
72
+ let memberSinceValue = processItem('memberSince', '0').replace(/(\d{1,2})(st|nd|th)/, "$1");
73
+
74
+ if (memberSinceValue.indexOf(',') === -1) {
75
+ memberSinceValue += ', ' + new Date().getFullYear();
76
+ }
77
+
78
+ this.memberSince = new Date(memberSinceValue);
79
+ this.location = processItem('location');
80
+ this.realName = processItem('realname');
81
+ this.summary = processItem('summary');
82
+ } else {
83
+ this.memberSince = null;
84
+ this.location = null;
85
+ this.realName = null;
86
+ this.summary = null;
87
+ }
88
+
89
+ // Maybe handle mostPlayedGames?
90
+
91
+ this.groups = null;
92
+ this.primaryGroup = null;
93
+
94
+ var self = this;
95
+ if(userData.groups && userData.groups[0] && userData.groups[0].group) {
96
+ this.groups = userData.groups[0].group.map(function(group) {
97
+ if(group['$'] && group['$'].isPrimary === "1") {
98
+ self.primaryGroup = new SteamID(group.groupID64[0]);
99
+ }
100
+
101
+ return new SteamID(group.groupID64[0]);
102
+ });
103
+ }
104
+
105
+ function processItem(name, defaultVal) {
106
+ if(!userData[name]) {
107
+ return defaultVal;
108
+ }
109
+
110
+ return userData[name][0];
111
+ }
112
+ }
113
+
114
+ CSteamUser.getAvatarURL = function(hash, size, protocol) {
115
+ size = size || '';
116
+ protocol = protocol || 'http://';
117
+
118
+ hash = hash || "72f78b4c8cc1f62323f8a33f6d53e27db57c2252"; // The default "?" avatar
119
+
120
+ var url = protocol + "steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + hash.substring(0, 2) + "/" + hash;
121
+ if(size == 'full' || size == 'medium') {
122
+ return url + "_" + size + ".jpg";
123
+ } else {
124
+ return url + ".jpg";
125
+ }
126
+ };
127
+
128
+ CSteamUser.prototype.getAvatarURL = function(size, protocol) {
129
+ return CSteamUser.getAvatarURL(this.avatarHash, size, protocol);
130
+ };
131
+
132
+ CSteamUser.prototype.addFriend = function(callback) {
133
+ this._community.addFriend(this.steamID, callback);
134
+ };
135
+
136
+ CSteamUser.prototype.acceptFriendRequest = function(callback) {
137
+ this._community.acceptFriendRequest(this.steamID, callback);
138
+ };
139
+
140
+ CSteamUser.prototype.removeFriend = function(callback) {
141
+ this._community.removeFriend(this.steamID, callback);
142
+
143
+ };
144
+
145
+ CSteamUser.prototype.blockCommunication = function(callback) {
146
+ this._community.blockCommunication(this.steamID, callback);
147
+ };
148
+
149
+ CSteamUser.prototype.unblockCommunication = function(callback) {
150
+ this._community.unblockCommunication(this.steamID, callback);
151
+ };
152
+
153
+ CSteamUser.prototype.comment = function(message, callback) {
154
+ this._community.postUserComment(this.steamID, message, callback);
155
+ };
156
+
157
+ CSteamUser.prototype.deleteComment = function(commentID, callback) {
158
+ this._community.deleteUserComment(this.steamID, commentID, callback);
159
+ };
160
+
161
+ CSteamUser.prototype.getComments = function(options, callback) {
162
+ this._community.getUserComments(this.steamID, options, callback);
163
+ };
164
+
165
+ CSteamUser.prototype.inviteToGroup = function(groupID, callback) {
166
+ this._community.inviteUserToGroup(this.steamID, groupID, callback);
167
+ };
168
+
169
+ CSteamUser.prototype.follow = function(callback) {
170
+ this._community.followUser(this.steamID, callback);
171
+ };
172
+
173
+ CSteamUser.prototype.unfollow = function(callback) {
174
+ this._community.unfollowUser(this.steamID, callback);
175
+ };
176
+
177
+ CSteamUser.prototype.getAliases = function(callback) {
178
+ this._community.getUserAliases(this.steamID, callback);
179
+ };
180
+
181
+ CSteamUser.prototype.getInventoryContexts = function(callback) {
182
+ this._community.getUserInventoryContexts(this.steamID, callback);
183
+ };
184
+
185
+ /**
186
+ * Get the contents of a user's inventory context.
187
+ * @deprecated Use CSteamUser#getInventoryContents instead
188
+ * @param {int} appID - The Steam application ID of the game for which you want an inventory
189
+ * @param {int} contextID - The ID of the "context" within the game you want to retrieve
190
+ * @param {boolean} tradableOnly - true to get only tradable items and currencies
191
+ * @param callback
192
+ */
193
+ CSteamUser.prototype.getInventory = function(appID, contextID, tradableOnly, callback) {
194
+ this._community.getUserInventory(this.steamID, appID, contextID, tradableOnly, callback);
195
+ };
196
+
197
+ /**
198
+ * Get the contents of a user's inventory context.
199
+ * @param {int} appID - The Steam application ID of the game for which you want an inventory
200
+ * @param {int} contextID - The ID of the "context" within the game you want to retrieve
201
+ * @param {boolean} tradableOnly - true to get only tradable items and currencies
202
+ * @param {string} [language] - The language of item descriptions to return. Omit for default (which may either be English or your account's chosen language)
203
+ * @param callback
204
+ */
205
+ CSteamUser.prototype.getInventoryContents = function(appID, contextID, tradableOnly, language, callback) {
206
+ this._community.getUserInventoryContents(this.steamID, appID, contextID, tradableOnly, language, callback);
207
+ };
208
+
209
+ /**
210
+ * Get the background URL of user's profile.
211
+ * @param {function} callback
212
+ */
213
+ CSteamUser.prototype.getProfileBackground = function(callback) {
214
+ this._community.getUserProfileBackground(this.steamID, callback);
215
+ };
216
+
217
+ /**
218
+ * Upload an image to Steam and send it to the target user over chat.
219
+ * @param {Buffer} imageContentsBuffer - The image contents, as a Buffer
220
+ * @param {{spoiler?: boolean}} [options]
221
+ * @param {function} callback
222
+ */
223
+ CSteamUser.prototype.sendImage = function(imageContentsBuffer, options, callback) {
224
+ this._community.sendImageToUser(this.steamID, imageContentsBuffer, options, callback);
225
+ };