steamutils 1.3.40 → 1.3.42
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +55 -9
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import NodeSteamUser from "steam-user";
|
2
2
|
import _ from "lodash";
|
3
3
|
import fs from "fs";
|
4
4
|
import {protoDecode, protoEncode} from "./helpers/util.js";
|
@@ -8,7 +8,7 @@ import axios from "axios";
|
|
8
8
|
import helpers, {loadProfos} from "./helpers/protos.js";
|
9
9
|
import {fileURLToPath} from "url";
|
10
10
|
import path from "path";
|
11
|
-
import
|
11
|
+
import SteamUser from "./index.js";
|
12
12
|
import {v4 as uuidv4} from 'uuid';
|
13
13
|
import EFriendRelationship from "steam-user/enums/EFriendRelationship.js";
|
14
14
|
import SteamCommunity from "steamcommunity";
|
@@ -78,7 +78,7 @@ const AppID = 730
|
|
78
78
|
export let CSGO_VER = 13960
|
79
79
|
export const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, 'free_packages.json'))).packages
|
80
80
|
|
81
|
-
|
81
|
+
SteamUser.getAppVersion(AppID).then(function (ver) {
|
82
82
|
CSGO_VER = ver
|
83
83
|
})
|
84
84
|
|
@@ -99,7 +99,7 @@ function SteamClient({
|
|
99
99
|
autoReconnect = true,
|
100
100
|
MAX_GAME_PLAY = 10
|
101
101
|
}) {
|
102
|
-
const steamClient = new
|
102
|
+
const steamClient = new NodeSteamUser()
|
103
103
|
let prime = null
|
104
104
|
let state = 'Offline'//InGame, Online, Invisible
|
105
105
|
let isLogOff = false
|
@@ -1560,7 +1560,7 @@ function SteamClient({
|
|
1560
1560
|
}
|
1561
1561
|
|
1562
1562
|
function getFriendList() {
|
1563
|
-
return Object.keys(steamClient.myFriends).filter(steamId => steamClient.myFriends[steamId] ===
|
1563
|
+
return Object.keys(steamClient.myFriends).filter(steamId => steamClient.myFriends[steamId] === NodeSteamUser.EFriendRelationship.Friend)
|
1564
1564
|
}
|
1565
1565
|
|
1566
1566
|
function sendFriendTyping(steamId, callback) {
|
@@ -1691,7 +1691,7 @@ function SteamClient({
|
|
1691
1691
|
return true
|
1692
1692
|
} else if (cookie) {
|
1693
1693
|
log(reconnect ? 'reconnect with cookie' : 'login with cookie')
|
1694
|
-
const _clientJsToken = await new
|
1694
|
+
const _clientJsToken = await new SteamUser(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken()
|
1695
1695
|
if (_clientJsToken?.logged_in === true) {
|
1696
1696
|
try {
|
1697
1697
|
await steamClient.logOn(_clientJsToken)
|
@@ -1940,10 +1940,10 @@ function SteamClient({
|
|
1940
1940
|
|
1941
1941
|
function updateInvisible() {
|
1942
1942
|
if (isInvisible) {
|
1943
|
-
steamClient.setPersona(
|
1943
|
+
steamClient.setPersona(NodeSteamUser.EPersonaState.Invisible)
|
1944
1944
|
state = 'Invisible'
|
1945
1945
|
} else {
|
1946
|
-
steamClient.setPersona(
|
1946
|
+
steamClient.setPersona(NodeSteamUser.EPersonaState.Online)
|
1947
1947
|
state = 'Online'
|
1948
1948
|
}
|
1949
1949
|
}
|
@@ -1955,7 +1955,7 @@ function SteamClient({
|
|
1955
1955
|
|
1956
1956
|
steamClient.gamesPlayed(apps);
|
1957
1957
|
await sleep(2000)
|
1958
|
-
// steamClient.setPersona(
|
1958
|
+
// steamClient.setPersona(NodeSteamUser.EPersonaState.Online)
|
1959
1959
|
await sendHello()
|
1960
1960
|
updateFakeGameScore()
|
1961
1961
|
|
@@ -2267,3 +2267,49 @@ export default SteamClient
|
|
2267
2267
|
export function increaseCSGO_VER() {
|
2268
2268
|
return ++CSGO_VER
|
2269
2269
|
}
|
2270
|
+
|
2271
|
+
SteamClient.isAccountPlayable = function isAccountPlayable(cookie, timeoutMs) {
|
2272
|
+
return new Promise((resolve) => {
|
2273
|
+
const timeout = setTimeout(() => {
|
2274
|
+
doResolve();
|
2275
|
+
}, timeoutMs || 30000);
|
2276
|
+
|
2277
|
+
const steamClient = new SteamClient({
|
2278
|
+
cookie,
|
2279
|
+
isFakeGameScore: false,
|
2280
|
+
isAutoPlay: true,
|
2281
|
+
isPartyRegister: false,
|
2282
|
+
isInvisible: false,
|
2283
|
+
MAX_GAME_PLAY: 10,
|
2284
|
+
});
|
2285
|
+
|
2286
|
+
steamClient.onEvent("error", ({eresult, msg, error}) => {
|
2287
|
+
doResolve();
|
2288
|
+
});
|
2289
|
+
|
2290
|
+
steamClient.onEvent("csgoOnline", ClientWelcome => {
|
2291
|
+
doResolve(ClientWelcome);
|
2292
|
+
});
|
2293
|
+
|
2294
|
+
steamClient.onEvent("csgoClientHello", ClientHello => {
|
2295
|
+
doResolve(ClientHello);
|
2296
|
+
});
|
2297
|
+
|
2298
|
+
steamClient.onEvent("playingState", ({playing_blocked, playing_app}) => {
|
2299
|
+
if (playing_blocked) {
|
2300
|
+
doResolve();
|
2301
|
+
}
|
2302
|
+
},
|
2303
|
+
);
|
2304
|
+
|
2305
|
+
steamClient.init();
|
2306
|
+
|
2307
|
+
function doResolve(data) {
|
2308
|
+
clearTimeout(timeout);
|
2309
|
+
steamClient.doClearIntervals();
|
2310
|
+
steamClient.offAllEvent();
|
2311
|
+
steamClient.logOff();
|
2312
|
+
return resolve(!!data);
|
2313
|
+
}
|
2314
|
+
});
|
2315
|
+
}
|