steamcommunity 3.46.1 → 3.47.1

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 (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +22 -22
  3. package/classes/CConfirmation.js +37 -37
  4. package/classes/CEconItem.js +120 -120
  5. package/classes/CMarketItem.js +189 -189
  6. package/classes/CMarketSearchResult.js +89 -89
  7. package/classes/CSteamGroup.js +155 -155
  8. package/classes/CSteamUser.js +225 -217
  9. package/components/chat.js +283 -283
  10. package/components/confirmations.js +428 -428
  11. package/components/groups.js +798 -732
  12. package/components/help.js +64 -64
  13. package/components/helpers.js +128 -108
  14. package/components/http.js +150 -150
  15. package/components/inventoryhistory.js +173 -173
  16. package/components/login.js +110 -0
  17. package/components/market.js +387 -387
  18. package/components/profile.js +475 -475
  19. package/components/twofactor.js +152 -152
  20. package/components/users.js +831 -767
  21. package/components/webapi.js +118 -118
  22. package/examples/README.md +35 -35
  23. package/examples/accept_all_confirmations.js +173 -173
  24. package/examples/disable_twofactor.js +135 -135
  25. package/examples/edit-group-announcement.js +118 -118
  26. package/examples/enable_twofactor.js +182 -182
  27. package/index.js +13 -151
  28. package/package.json +11 -6
  29. package/resources/EChatState.js +14 -14
  30. package/resources/EConfirmationType.js +12 -12
  31. package/resources/EFriendRelationship.js +23 -23
  32. package/resources/EPersonaState.js +23 -23
  33. package/resources/EPersonaStateFlag.js +32 -32
  34. package/resources/EResult.js +254 -254
  35. package/.editorconfig +0 -13
  36. package/.github/FUNDING.yml +0 -2
  37. package/.idea/.name +0 -1
  38. package/.idea/codeStyleSettings.xml +0 -13
  39. package/.idea/codeStyles/Project.xml +0 -15
  40. package/.idea/codeStyles/codeStyleConfig.xml +0 -6
  41. package/.idea/copyright/profiles_settings.xml +0 -3
  42. package/.idea/encodings.xml +0 -6
  43. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  44. package/.idea/jsLibraryMappings.xml +0 -6
  45. package/.idea/misc.xml +0 -6
  46. package/.idea/modules.xml +0 -9
  47. package/.idea/node-steamcommunity.iml +0 -8
  48. package/.idea/steamcommunity.iml +0 -10
  49. package/.idea/vcs.xml +0 -7
  50. package/.idea/watcherTasks.xml +0 -4
  51. package/CONTRIBUTING.md +0 -36
@@ -1,189 +1,189 @@
1
- var SteamCommunity = require('../index.js');
2
- var Cheerio = require('cheerio');
3
-
4
- SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, callback) {
5
- if (typeof currency == "function") {
6
- callback = currency;
7
- currency = 1;
8
- }
9
- var self = this;
10
- this.httpRequest("https://steamcommunity.com/market/listings/" + appid + "/" + encodeURIComponent(hashName), function(err, response, body) {
11
- if (err) {
12
- callback(err);
13
- return;
14
- }
15
-
16
- var $ = Cheerio.load(body);
17
- if($('.market_listing_table_message') && $('.market_listing_table_message').text().trim() == 'There are no listings for this item.') {
18
- callback(new Error("There are no listings for this item."));
19
- return;
20
- }
21
-
22
- var item = new CMarketItem(appid, hashName, self, body, $);
23
- item.updatePrice(currency, function(err) {
24
- if(err) {
25
- callback(err);
26
- } else {
27
- callback(null, item);
28
- }
29
- });
30
- }, "steamcommunity");
31
- };
32
-
33
- function CMarketItem(appid, hashName, community, body, $) {
34
- this._appid = appid;
35
- this._hashName = hashName;
36
- this._community = community;
37
- this._$ = $;
38
-
39
- this._country = "US";
40
- var match = body.match(/var g_strCountryCode = "([^"]+)";/);
41
- if(match) {
42
- this._country = match[1];
43
- }
44
-
45
- this._language = "english";
46
- match = body.match(/var g_strLanguage = "([^"]+)";/);
47
- if(match) {
48
- this._language = match[1];
49
- }
50
-
51
- this.commodity = false;
52
- match = body.match(/Market_LoadOrderSpread\(\s*(\d+)\s*\);/);
53
- if(match) {
54
- this.commodity = true;
55
- this.commodityID = parseInt(match[1], 10);
56
- }
57
-
58
- this.medianSalePrices = null;
59
- match = body.match(/var line1=([^;]+);/);
60
- if(match) {
61
- try {
62
- this.medianSalePrices = JSON.parse(match[1]);
63
- this.medianSalePrices = this.medianSalePrices.map(function(item) {
64
- return {
65
- "hour": new Date(item[0]),
66
- "price": item[1],
67
- "quantity": parseInt(item[2], 10)
68
- };
69
- });
70
- } catch(e) {
71
- // ignore
72
- }
73
- }
74
-
75
- this.firstAsset = null;
76
- this.assets = null;
77
- match = body.match(/var g_rgAssets = (.*);/);
78
- if (match) {
79
- try {
80
- this.assets = JSON.parse(match[1]);
81
- this.assets = this.assets[appid];
82
- this.assets = this.assets[Object.keys(this.assets)[0]];
83
- this.firstAsset = this.assets[Object.keys(this.assets)[0]];
84
- } catch (e) {
85
- // ignore
86
- }
87
- }
88
-
89
- this.quantity = 0;
90
- this.lowestPrice = 0;
91
- // TODO: Buying listings and placing buy orders
92
- }
93
-
94
- CMarketItem.prototype.updatePrice = function (currency, callback) {
95
- if (this.commodity) {
96
- this.updatePriceForCommodity(currency, callback);
97
- } else {
98
- this.updatePriceForNonCommodity(currency, callback);
99
- }
100
- };
101
-
102
- CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) {
103
- if(!this.commodity) {
104
- throw new Error("Cannot update price for non-commodity item");
105
- }
106
-
107
- var self = this;
108
- this._community.httpRequest({
109
- "uri": "https://steamcommunity.com/market/itemordershistogram?country=US&language=english&currency=" + currency + "&item_nameid=" + this.commodityID,
110
- "json": true
111
- }, function(err, response, body) {
112
- if (err) {
113
- callback(err);
114
- return;
115
- }
116
-
117
- if(body.success != 1) {
118
- if(callback) {
119
- callback(new Error("Error " + body.success));
120
- }
121
-
122
- return;
123
- }
124
-
125
- var match = (body.sell_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
126
- if(match) {
127
- self.quantity = parseInt(match[1], 10);
128
- }
129
-
130
- self.buyQuantity = 0;
131
- match = (body.buy_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
132
- if(match) {
133
- self.buyQuantity = parseInt(match[1], 10);
134
- }
135
-
136
- self.lowestPrice = parseInt(body.lowest_sell_order, 10);
137
- self.highestBuyOrder = parseInt(body.highest_buy_order, 10);
138
-
139
- // TODO: The tables?
140
- if(callback) {
141
- callback(null);
142
- }
143
- }, "steamcommunity");
144
- };
145
-
146
- CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) {
147
- if(this.commodity) {
148
- throw new Error("Cannot update price for commodity item");
149
- }
150
-
151
- var self = this;
152
- this._community.httpRequest({
153
- "uri": "https://steamcommunity.com/market/listings/" +
154
- this._appid + "/" +
155
- encodeURIComponent(this._hashName) +
156
- "/render/?query=&start=0&count=10&country=US&language=english&currency=" + currency,
157
- "json": true
158
- }, function(err, response, body) {
159
- if (err) {
160
- callback(err);
161
- return;
162
- }
163
-
164
- if (body.success != 1) {
165
- callback && callback(new Error("Error " + body.success));
166
- return;
167
- }
168
-
169
- var match = body.total_count;
170
- if (match) {
171
- self.quantity = parseInt(match, 10);
172
- }
173
-
174
- var lowestPrice;
175
- var $ = Cheerio.load(body.results_html);
176
- match = $(".market_listing_price.market_listing_price_with_fee");
177
- if (match) {
178
- for (var i = 0; i < match.length; i++) {
179
- lowestPrice = parseFloat($(match[i]).text().replace(",", ".").replace(/[^\d.]/g, ''));
180
- if (!isNaN(lowestPrice)) {
181
- self.lowestPrice = lowestPrice;
182
- break;
183
- }
184
- }
185
- }
186
-
187
- callback && callback(null);
188
- }, "steamcommunity");
189
- };
1
+ var SteamCommunity = require('../index.js');
2
+ var Cheerio = require('cheerio');
3
+
4
+ SteamCommunity.prototype.getMarketItem = function(appid, hashName, currency, callback) {
5
+ if (typeof currency == "function") {
6
+ callback = currency;
7
+ currency = 1;
8
+ }
9
+ var self = this;
10
+ this.httpRequest("https://steamcommunity.com/market/listings/" + appid + "/" + encodeURIComponent(hashName), function(err, response, body) {
11
+ if (err) {
12
+ callback(err);
13
+ return;
14
+ }
15
+
16
+ var $ = Cheerio.load(body);
17
+ if($('.market_listing_table_message') && $('.market_listing_table_message').text().trim() == 'There are no listings for this item.') {
18
+ callback(new Error("There are no listings for this item."));
19
+ return;
20
+ }
21
+
22
+ var item = new CMarketItem(appid, hashName, self, body, $);
23
+ item.updatePrice(currency, function(err) {
24
+ if(err) {
25
+ callback(err);
26
+ } else {
27
+ callback(null, item);
28
+ }
29
+ });
30
+ }, "steamcommunity");
31
+ };
32
+
33
+ function CMarketItem(appid, hashName, community, body, $) {
34
+ this._appid = appid;
35
+ this._hashName = hashName;
36
+ this._community = community;
37
+ this._$ = $;
38
+
39
+ this._country = "US";
40
+ var match = body.match(/var g_strCountryCode = "([^"]+)";/);
41
+ if(match) {
42
+ this._country = match[1];
43
+ }
44
+
45
+ this._language = "english";
46
+ match = body.match(/var g_strLanguage = "([^"]+)";/);
47
+ if(match) {
48
+ this._language = match[1];
49
+ }
50
+
51
+ this.commodity = false;
52
+ match = body.match(/Market_LoadOrderSpread\(\s*(\d+)\s*\);/);
53
+ if(match) {
54
+ this.commodity = true;
55
+ this.commodityID = parseInt(match[1], 10);
56
+ }
57
+
58
+ this.medianSalePrices = null;
59
+ match = body.match(/var line1=([^;]+);/);
60
+ if(match) {
61
+ try {
62
+ this.medianSalePrices = JSON.parse(match[1]);
63
+ this.medianSalePrices = this.medianSalePrices.map(function(item) {
64
+ return {
65
+ "hour": new Date(item[0]),
66
+ "price": item[1],
67
+ "quantity": parseInt(item[2], 10)
68
+ };
69
+ });
70
+ } catch(e) {
71
+ // ignore
72
+ }
73
+ }
74
+
75
+ this.firstAsset = null;
76
+ this.assets = null;
77
+ match = body.match(/var g_rgAssets = (.*);/);
78
+ if (match) {
79
+ try {
80
+ this.assets = JSON.parse(match[1]);
81
+ this.assets = this.assets[appid];
82
+ this.assets = this.assets[Object.keys(this.assets)[0]];
83
+ this.firstAsset = this.assets[Object.keys(this.assets)[0]];
84
+ } catch (e) {
85
+ // ignore
86
+ }
87
+ }
88
+
89
+ this.quantity = 0;
90
+ this.lowestPrice = 0;
91
+ // TODO: Buying listings and placing buy orders
92
+ }
93
+
94
+ CMarketItem.prototype.updatePrice = function (currency, callback) {
95
+ if (this.commodity) {
96
+ this.updatePriceForCommodity(currency, callback);
97
+ } else {
98
+ this.updatePriceForNonCommodity(currency, callback);
99
+ }
100
+ };
101
+
102
+ CMarketItem.prototype.updatePriceForCommodity = function(currency, callback) {
103
+ if(!this.commodity) {
104
+ throw new Error("Cannot update price for non-commodity item");
105
+ }
106
+
107
+ var self = this;
108
+ this._community.httpRequest({
109
+ "uri": "https://steamcommunity.com/market/itemordershistogram?country=US&language=english&currency=" + currency + "&item_nameid=" + this.commodityID,
110
+ "json": true
111
+ }, function(err, response, body) {
112
+ if (err) {
113
+ callback(err);
114
+ return;
115
+ }
116
+
117
+ if(body.success != 1) {
118
+ if(callback) {
119
+ callback(new Error("Error " + body.success));
120
+ }
121
+
122
+ return;
123
+ }
124
+
125
+ var match = (body.sell_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
126
+ if(match) {
127
+ self.quantity = parseInt(match[1], 10);
128
+ }
129
+
130
+ self.buyQuantity = 0;
131
+ match = (body.buy_order_summary || '').match(/<span class="market_commodity_orders_header_promote">(\d+)<\/span>/);
132
+ if(match) {
133
+ self.buyQuantity = parseInt(match[1], 10);
134
+ }
135
+
136
+ self.lowestPrice = parseInt(body.lowest_sell_order, 10);
137
+ self.highestBuyOrder = parseInt(body.highest_buy_order, 10);
138
+
139
+ // TODO: The tables?
140
+ if(callback) {
141
+ callback(null);
142
+ }
143
+ }, "steamcommunity");
144
+ };
145
+
146
+ CMarketItem.prototype.updatePriceForNonCommodity = function (currency, callback) {
147
+ if(this.commodity) {
148
+ throw new Error("Cannot update price for commodity item");
149
+ }
150
+
151
+ var self = this;
152
+ this._community.httpRequest({
153
+ "uri": "https://steamcommunity.com/market/listings/" +
154
+ this._appid + "/" +
155
+ encodeURIComponent(this._hashName) +
156
+ "/render/?query=&start=0&count=10&country=US&language=english&currency=" + currency,
157
+ "json": true
158
+ }, function(err, response, body) {
159
+ if (err) {
160
+ callback(err);
161
+ return;
162
+ }
163
+
164
+ if (body.success != 1) {
165
+ callback && callback(new Error("Error " + body.success));
166
+ return;
167
+ }
168
+
169
+ var match = body.total_count;
170
+ if (match) {
171
+ self.quantity = parseInt(match, 10);
172
+ }
173
+
174
+ var lowestPrice;
175
+ var $ = Cheerio.load(body.results_html);
176
+ match = $(".market_listing_price.market_listing_price_with_fee");
177
+ if (match) {
178
+ for (var i = 0; i < match.length; i++) {
179
+ lowestPrice = parseFloat($(match[i]).text().replace(",", ".").replace(/[^\d.]/g, ''));
180
+ if (!isNaN(lowestPrice)) {
181
+ self.lowestPrice = lowestPrice;
182
+ break;
183
+ }
184
+ }
185
+ }
186
+
187
+ callback && callback(null);
188
+ }, "steamcommunity");
189
+ };
@@ -1,89 +1,89 @@
1
- var SteamCommunity = require('../index.js');
2
- var Cheerio = require('cheerio');
3
-
4
- SteamCommunity.prototype.marketSearch = function(options, callback) {
5
- var qs = {};
6
-
7
- if(typeof options === 'string') {
8
- qs.query = options;
9
- } else {
10
- qs.query = options.query || '';
11
- qs.appid = options.appid;
12
- qs.search_descriptions = options.searchDescriptions ? 1 : 0;
13
-
14
- if(qs.appid) {
15
- for(var i in options) {
16
- if(['query', 'appid', 'searchDescriptions'].indexOf(i) != -1) {
17
- continue;
18
- }
19
-
20
- // This is a tag
21
- qs['category_' + qs.appid + '_' + i + '[]'] = 'tag_' + options[i];
22
- }
23
- }
24
- }
25
-
26
- qs.start = 0;
27
- qs.count = 100;
28
- qs.sort_column = 'price';
29
- qs.sort_dir = 'asc';
30
-
31
- var self = this;
32
- var results = [];
33
- performSearch();
34
-
35
- function performSearch() {
36
- self.httpRequest({
37
- "uri": "https://steamcommunity.com/market/search/render/",
38
- "qs": qs,
39
- "headers": {
40
- "referer": "https://steamcommunity.com/market/search"
41
- },
42
- "json": true
43
- }, function(err, response, body) {
44
- if (err) {
45
- callback(err);
46
- return;
47
- }
48
-
49
- if(!body.success) {
50
- callback(new Error("Success is not true"));
51
- return;
52
- }
53
-
54
- if(!body.results_html) {
55
- callback(new Error("No results_html in response"));
56
- return;
57
- }
58
-
59
- var $ = Cheerio.load(body.results_html);
60
- var $errorMsg = $('.market_listing_table_message');
61
- if($errorMsg.length > 0) {
62
- callback(new Error($errorMsg.text()));
63
- return;
64
- }
65
-
66
- var rows = $('.market_listing_row_link');
67
- for(var i = 0; i < rows.length; i++) {
68
- results.push(new CMarketSearchResult($(rows[i])));
69
- }
70
-
71
- if(body.start + body.pagesize >= body.total_count) {
72
- callback(null, results);
73
- } else {
74
- qs.start += body.pagesize;
75
- performSearch();
76
- }
77
- }, "steamcommunity");
78
- }
79
- };
80
-
81
- function CMarketSearchResult(row) {
82
- var match = row.attr('href').match(/\/market\/listings\/(\d+)\/([^\?\/]+)/);
83
-
84
- this.appid = parseInt(match[1], 10);
85
- this.market_hash_name = decodeURIComponent(match[2]);
86
- this.image = ((row.find('.market_listing_item_img').attr('src') || "").match(/^https?:\/\/[^\/]+\/economy\/image\/[^\/]+\//) || [])[0];
87
- this.price = parseInt(row.find('.market_listing_their_price .market_table_value span.normal_price').text().replace(/[^\d]+/g, ''), 10);
88
- this.quantity = parseInt(row.find('.market_listing_num_listings_qty').text().replace(/[^\d]+/g, ''), 10);
89
- }
1
+ var SteamCommunity = require('../index.js');
2
+ var Cheerio = require('cheerio');
3
+
4
+ SteamCommunity.prototype.marketSearch = function(options, callback) {
5
+ var qs = {};
6
+
7
+ if(typeof options === 'string') {
8
+ qs.query = options;
9
+ } else {
10
+ qs.query = options.query || '';
11
+ qs.appid = options.appid;
12
+ qs.search_descriptions = options.searchDescriptions ? 1 : 0;
13
+
14
+ if(qs.appid) {
15
+ for(var i in options) {
16
+ if(['query', 'appid', 'searchDescriptions'].indexOf(i) != -1) {
17
+ continue;
18
+ }
19
+
20
+ // This is a tag
21
+ qs['category_' + qs.appid + '_' + i + '[]'] = 'tag_' + options[i];
22
+ }
23
+ }
24
+ }
25
+
26
+ qs.start = 0;
27
+ qs.count = 100;
28
+ qs.sort_column = 'price';
29
+ qs.sort_dir = 'asc';
30
+
31
+ var self = this;
32
+ var results = [];
33
+ performSearch();
34
+
35
+ function performSearch() {
36
+ self.httpRequest({
37
+ "uri": "https://steamcommunity.com/market/search/render/",
38
+ "qs": qs,
39
+ "headers": {
40
+ "referer": "https://steamcommunity.com/market/search"
41
+ },
42
+ "json": true
43
+ }, function(err, response, body) {
44
+ if (err) {
45
+ callback(err);
46
+ return;
47
+ }
48
+
49
+ if(!body.success) {
50
+ callback(new Error("Success is not true"));
51
+ return;
52
+ }
53
+
54
+ if(!body.results_html) {
55
+ callback(new Error("No results_html in response"));
56
+ return;
57
+ }
58
+
59
+ var $ = Cheerio.load(body.results_html);
60
+ var $errorMsg = $('.market_listing_table_message');
61
+ if($errorMsg.length > 0) {
62
+ callback(new Error($errorMsg.text()));
63
+ return;
64
+ }
65
+
66
+ var rows = $('.market_listing_row_link');
67
+ for(var i = 0; i < rows.length; i++) {
68
+ results.push(new CMarketSearchResult($(rows[i])));
69
+ }
70
+
71
+ if(body.start + body.pagesize >= body.total_count) {
72
+ callback(null, results);
73
+ } else {
74
+ qs.start += body.pagesize;
75
+ performSearch();
76
+ }
77
+ }, "steamcommunity");
78
+ }
79
+ };
80
+
81
+ function CMarketSearchResult(row) {
82
+ var match = row.attr('href').match(/\/market\/listings\/(\d+)\/([^\?\/]+)/);
83
+
84
+ this.appid = parseInt(match[1], 10);
85
+ this.market_hash_name = decodeURIComponent(match[2]);
86
+ this.image = ((row.find('.market_listing_item_img').attr('src') || "").match(/^https?:\/\/[^\/]+\/economy\/image\/[^\/]+\//) || [])[0];
87
+ this.price = parseInt(row.find('.market_listing_their_price .market_table_value span.normal_price').text().replace(/[^\d]+/g, ''), 10);
88
+ this.quantity = parseInt(row.find('.market_listing_num_listings_qty').text().replace(/[^\d]+/g, ''), 10);
89
+ }