steam-family-bot-core
Version:
一个用于新版 Steam 家庭的库存监控 Bot 插件
67 lines • 2.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalFamilyAPI = void 0;
const utils_1 = require("../../utils");
const node_steam_family_group_api_1 = require("node-steam-family-group-api");
const interface_1 = require("../interface");
class LocalFamilyAPI extends interface_1.ISteamFamilyAPI {
steamAPI;
helperAPIHost;
constructor(helperApiHost, logger, token) {
super();
if (helperApiHost.endsWith('/')) {
this.helperAPIHost = helperApiHost.slice(0, helperApiHost.length - 1);
}
else {
this.helperAPIHost = helperApiHost;
}
this.updateSteamToken(token);
}
updateSteamToken(token) {
this.token = token;
this.steamAPI = new node_steam_family_group_api_1.SteamAPI(token);
// use steam-family-lib-viewer's api to proxy some proto api
try {
const tokenInfo = (0, utils_1.jwtDecode)(token ?? '');
this.steamId = BigInt(tokenInfo.sub);
}
catch (e) {
// ignore for non token
}
}
getSteamFamilyGroup = (token = this.token, steamId = this.steamId) => this.steamAPI.familyGroup.getFamilyGroupForUser({ steamid: steamId, includeFamilyGroupResponse: true }, token);
getPlaytimeSummary = (familyGroupid, token = this.token) => this.steamAPI.familyGroup.getFamilyGroupPlaytimeSummary({ familyGroupid: familyGroupid }, token);
getSteamFamilyGroupLibs = (familyId, token = this.token) => this.steamAPI.familyGroup.getFamilyGroupShardLibrary({
familyGroupid: familyId,
includeOwn: true,
includeExcluded: true,
language: 'schinese',
}, token);
getFamilyMembers = (memberIds, token = this.token) => this.steamAPI.common.getSteamPlayerLinkDetails({ steamids: memberIds.map((it) => BigInt(it)) }, token);
getSteamItems = async (appIds, params) => this.steamAPI.common.getSteamItemsById(params ?? {
ids: appIds
.map((it) => parseInt(it))
.filter((it) => !Number.isNaN(it))
.map((it) => ({ appid: it })),
context: {
language: 'schinese',
countryCode: 'US',
steamRealm: 1,
},
dataRequest: {
includeAssets: true,
includeRelease: true,
includePlatforms: true,
includeScreenshots: true,
includeTrailers: true,
includeIncludedItems: true,
includeTagCount: 20,
},
});
getSteamItemsBaseInfo(appIds) {
const url = `${this.helperAPIHost}/api/steam/info/${appIds.join(',')}`;
return fetch(url).then((res) => res.json());
}
}
exports.LocalFamilyAPI = LocalFamilyAPI;
//# sourceMappingURL=local.js.map