steamutils 1.5.44 → 1.5.46
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/const.js +582 -570
- package/index.js +50 -24
- package/package.json +1 -1
package/index.js
CHANGED
@@ -17,7 +17,7 @@ import { StringUtils } from "alpha-common-utils/index.js";
|
|
17
17
|
import * as https from "https";
|
18
18
|
import path from "path";
|
19
19
|
import CookieManager from "./CookieManager.js";
|
20
|
-
import { AppID_CSGO, E1GameBanOnRecord, E1VACBanOnRecord, EActivityType, ECommentPrivacyState, ECurrentlyTradeBanned, EdaySinceLastBanRegExp, EFriendRelationship, ELanguage, EmptyProfileSummary, EMultipleGameBansOnRecord, EMultipleVACBansOnRecord, EPrivacyState, ErrorProcessingRequest, FRIEND_CODE_REPLACEMENTS, NotYetSetupProfileTextList, PrivacySettings, PrivateProfileTextList, SteamcommunityURL, SteamErrorTitle, SteamImageCDN } from "./const.js";
|
20
|
+
import { AppID_CSGO, E1GameBanOnRecord, E1VACBanOnRecord, EActivityType, ECommentPrivacyState, ECurrentlyTradeBanned, EdaySinceLastBanRegExp, EFriendRelationship, ELanguage, EmptyProfileSummary, EMultipleGameBansOnRecord, EMultipleVACBansOnRecord, EPrivacyState, ErrorProcessingRequest, FRIEND_CODE_REPLACEMENTS, MarketRestrictionReasonText, NotYetSetupProfileTextList, PrivacySettings, PrivateProfileTextList, SteamcommunityURL, SteamErrorTitle, SteamImageCDN } from "./const.js";
|
21
21
|
import SteamTotp from "steam-totp";
|
22
22
|
import { SteamProto, SteamProtoType } from "./steamproto.js";
|
23
23
|
import EventEmitter from "node:events";
|
@@ -6182,37 +6182,63 @@ export default class SteamUser {
|
|
6182
6182
|
return response;
|
6183
6183
|
}
|
6184
6184
|
|
6185
|
-
|
6185
|
+
/**
|
6186
|
+
* Fetches and parses Steam Market unavailability info.
|
6187
|
+
*
|
6188
|
+
* @returns {Promise<{
|
6189
|
+
* marketWarning?: string,
|
6190
|
+
* marketRestrictions?: string[],
|
6191
|
+
* marketRestrictionExpire?: string,
|
6192
|
+
* marketTimeCanUse?: number | null
|
6193
|
+
* } | null>} Parsed unavailability data, empty object, or null on error.
|
6194
|
+
*/
|
6195
|
+
async getMarketRestrictions() {
|
6186
6196
|
const result = await this._httpRequest(`market`);
|
6187
6197
|
if (result instanceof ResponseError) {
|
6188
|
-
return result;
|
6189
|
-
}
|
6190
|
-
const data = result?.data;
|
6191
|
-
if (!data) {
|
6192
6198
|
return null;
|
6193
6199
|
}
|
6200
|
+
const data = result?.data;
|
6201
|
+
if (!data) return null;
|
6202
|
+
|
6194
6203
|
const $ = cheerio.load(data);
|
6195
|
-
|
6196
|
-
const
|
6197
|
-
|
6198
|
-
|
6199
|
-
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6203
|
-
|
6204
|
-
|
6205
|
-
const market_restriction_expire = StringUtils.cleanSpace(market_headertip_container_warning_el.find("#market_restriction_expire").text());
|
6206
|
-
const market_timecanuse_header = StringUtils.cleanSpace(market_headertip_container_warning_el.find("#market_timecanuse_header").text());
|
6204
|
+
|
6205
|
+
const loginMsg1 = $("body").find(':contains("You need to sign in or create an account to do that.")').length;
|
6206
|
+
const loginMsg2 = $("body").find(':contains("Login to see, edit, or remove your Community Market listings")').length;
|
6207
|
+
const loginMsg3 = $("body").find(':contains("Login to view your Community Market history")').length;
|
6208
|
+
const loginLinkBlock = $(".market_login_link_ctn").length;
|
6209
|
+
if (loginMsg1 || loginMsg2 || loginMsg3 || loginLinkBlock) return null;
|
6210
|
+
|
6211
|
+
const warningContainer = $(".market_headertip_container_warning");
|
6212
|
+
const warningHeaderElement = warningContainer.find("#market_warning_header");
|
6213
|
+
if (!warningContainer.length || !warningHeaderElement.length) {
|
6207
6214
|
return {
|
6208
|
-
|
6209
|
-
|
6210
|
-
|
6211
|
-
|
6215
|
+
marketWarning: null,
|
6216
|
+
marketRestrictions: [],
|
6217
|
+
marketRestrictionExpire: null,
|
6218
|
+
marketTimeCanUse: null,
|
6212
6219
|
};
|
6213
|
-
} else {
|
6214
|
-
return {};
|
6215
6220
|
}
|
6221
|
+
|
6222
|
+
const marketWarning = StringUtils.cleanSpace(warningHeaderElement.text());
|
6223
|
+
|
6224
|
+
const restrictionMessages = [];
|
6225
|
+
warningContainer.find("ul.market_restrictions > li").each(function () {
|
6226
|
+
const el = $(this);
|
6227
|
+
el.find("a").remove();
|
6228
|
+
restrictionMessages.push(StringUtils.cleanSpace(el.text()));
|
6229
|
+
});
|
6230
|
+
|
6231
|
+
const marketRestrictions = restrictionMessages.map((message) => Object.entries(MarketRestrictionReasonText).find(([, text]) => text === message)?.[0] || message).filter(Boolean);
|
6232
|
+
const marketRestrictionExpire = StringUtils.cleanSpace(warningContainer.find("#market_restriction_expire").text());
|
6233
|
+
const marketTimeCanUse = StringUtils.cleanSpace(warningContainer.find("#market_timecanuse_header").text());
|
6234
|
+
const marketTimeCanUseMoment = moment(marketTimeCanUse, "ddd, DD MMM YYYY HH:mm:ss Z", true);
|
6235
|
+
|
6236
|
+
return {
|
6237
|
+
marketWarning,
|
6238
|
+
marketRestrictions,
|
6239
|
+
marketRestrictionExpire,
|
6240
|
+
marketTimeCanUse: marketTimeCanUseMoment.isValid() ? marketTimeCanUseMoment.valueOf() : null,
|
6241
|
+
};
|
6216
6242
|
}
|
6217
6243
|
|
6218
6244
|
async getAmountSpentOnSteam() {
|