steamutils 1.4.64 → 1.4.66
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +223 -137
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -94,8 +94,8 @@ export const SteamClientEvents = {
|
|
94
94
|
};
|
95
95
|
let isSendingFriendMessages = false;
|
96
96
|
|
97
|
-
function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense = true, isFakeGameScore = true, isPartyRegister = true, isAutoPlay = false, isInvisible = false, autoAcceptTradeRequest = false, autoReconnect = true,
|
98
|
-
|
97
|
+
function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense = true, isFakeGameScore = true, isPartyRegister = true, isAutoPlay = false, isInvisible = false, autoAcceptTradeRequest = false, autoReconnect = true, games = null }) {
|
98
|
+
let steamClient = null;
|
99
99
|
let prime = null;
|
100
100
|
let state = "Offline"; //InGame, Online, Invisible
|
101
101
|
let isLogOff = false;
|
@@ -119,11 +119,46 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
119
119
|
|
120
120
|
const onAnyCallbacks = [];
|
121
121
|
|
122
|
-
|
122
|
+
/**
|
123
|
+
* @type {Object.<string, Array>}
|
124
|
+
* @property {Array} user
|
125
|
+
* @property {Array} loggedOn
|
126
|
+
* @property {Array} csgoOnline
|
127
|
+
* @property {Array} csgoClientHello
|
128
|
+
* @property {Array} webSession
|
129
|
+
* @property {Array} friendMessage
|
130
|
+
* @property {Array} friendTyping
|
131
|
+
* @property {Array} disconnected
|
132
|
+
* @property {Array} error
|
133
|
+
* @property {Array} playersProfile
|
134
|
+
* @property {Array} fatalError
|
135
|
+
* @property {Array} partyInvite
|
136
|
+
* @property {Array} friendRelationship
|
137
|
+
* @property {Array} tradeOffers
|
138
|
+
* @property {Array} offlineMessages
|
139
|
+
* @property {Array} friendsList
|
140
|
+
* @property {Array} gifts
|
141
|
+
* @property {Array} playingState
|
142
|
+
* @property {Array} emailInfo
|
143
|
+
* @property {Array} accountLimitations
|
144
|
+
* @property {Array} wallet
|
145
|
+
* @property {Array} licenses
|
146
|
+
* @property {Array} logOff
|
147
|
+
*/
|
148
|
+
const events = {};
|
123
149
|
for (const name in SteamClientEvents) {
|
124
150
|
events[name] = [];
|
125
151
|
}
|
126
152
|
|
153
|
+
/**
|
154
|
+
* @typedef {Object} GCEvents
|
155
|
+
* @property {Array} requestJoinFriendData
|
156
|
+
* @property {Array} requestCoPlays
|
157
|
+
* @property {Array} partySearch
|
158
|
+
* @property {Array} playersProfile
|
159
|
+
*
|
160
|
+
* @type {GCEvents}
|
161
|
+
*/
|
127
162
|
const gcEvents = {
|
128
163
|
requestJoinFriendData: [],
|
129
164
|
requestCoPlays: [],
|
@@ -159,51 +194,23 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
159
194
|
}
|
160
195
|
|
161
196
|
function clearGCCallback(name) {
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
case "string":
|
168
|
-
if (Array.isArray(gcEvents[nameE])) {
|
169
|
-
//name
|
170
|
-
for (const eventElement of gcEvents[nameE]) {
|
171
|
-
if (eventElement.timeout) {
|
172
|
-
clearTimeout(eventElement.timeout);
|
173
|
-
}
|
174
|
-
}
|
175
|
-
gcEvents[nameE] = [];
|
176
|
-
} else {
|
177
|
-
//id
|
178
|
-
for (const eventsKey in gcEvents) {
|
179
|
-
if (!Array.isArray(gcEvents[eventsKey])) {
|
180
|
-
continue;
|
181
|
-
}
|
182
|
-
const index = gcEvents[eventsKey].findIndex((e) => e.id === nameE);
|
183
|
-
if (index > -1) {
|
184
|
-
if (gcEvents[eventsKey].timeout) {
|
185
|
-
clearTimeout(gcEvents[eventsKey].timeout);
|
186
|
-
}
|
187
|
-
gcEvents[eventsKey].splice(index, 1);
|
188
|
-
}
|
189
|
-
}
|
197
|
+
for (const [eventName, events] of Object.entries(gcEvents)) {
|
198
|
+
if (eventName === name) {
|
199
|
+
for (const event of events) {
|
200
|
+
if (event.timeout) {
|
201
|
+
clearTimeout(event.timeout);
|
190
202
|
}
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
if (gcEvents[eventsKey].timeout) {
|
201
|
-
clearTimeout(gcEvents[eventsKey].timeout);
|
202
|
-
}
|
203
|
-
gcEvents[eventsKey].splice(index, 1);
|
204
|
-
}
|
203
|
+
}
|
204
|
+
events.length = 0;
|
205
|
+
} else {
|
206
|
+
const removedEvents = _.remove(events, function (e) {
|
207
|
+
return Object.values(e).some((v) => v === name);
|
208
|
+
});
|
209
|
+
for (const removedEvent of removedEvents) {
|
210
|
+
if (removedEvent.timeout) {
|
211
|
+
clearTimeout(removedEvent.timeout);
|
205
212
|
}
|
206
|
-
|
213
|
+
}
|
207
214
|
}
|
208
215
|
}
|
209
216
|
}
|
@@ -217,14 +224,14 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
217
224
|
return;
|
218
225
|
}
|
219
226
|
|
220
|
-
const
|
227
|
+
const removedEvents = _.remove(gcEvents[name], (item) => !key || item.key === key);
|
221
228
|
let _data = null;
|
222
229
|
let calculated = false;
|
223
230
|
|
224
|
-
for (const
|
225
|
-
if (
|
226
|
-
clearTimeout(
|
227
|
-
delete
|
231
|
+
for (const removedEvent of removedEvents) {
|
232
|
+
if (removedEvent.timeout) {
|
233
|
+
clearTimeout(removedEvent.timeout);
|
234
|
+
delete removedEvent.timeout;
|
228
235
|
}
|
229
236
|
|
230
237
|
if (!calculated) {
|
@@ -232,23 +239,22 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
232
239
|
_data = typeof data === "function" ? await data() : data;
|
233
240
|
}
|
234
241
|
|
235
|
-
|
242
|
+
removedEvent.callback(_data);
|
236
243
|
}
|
237
244
|
}
|
238
245
|
|
239
|
-
function callEvent(
|
240
|
-
|
241
|
-
|
246
|
+
function callEvent(name, data) {
|
247
|
+
if (typeof name !== "string") {
|
248
|
+
name = Object.keys(events).find((eventName) => events[eventName] === name);
|
249
|
+
}
|
242
250
|
|
243
|
-
_events
|
251
|
+
const _events = events[name];
|
252
|
+
onAnyCallbacks.forEach((cb) => cb?.({ eventName: name, data }));
|
253
|
+
_events.forEach((e) => {
|
254
|
+
clearTimeout(e.timeout);
|
244
255
|
e.callback?.(data);
|
245
|
-
e.timeout && clearTimeout(e.timeout);
|
246
|
-
delete e.timeout;
|
247
|
-
if (e.once) {
|
248
|
-
delete e.callback;
|
249
|
-
}
|
250
256
|
});
|
251
|
-
_.remove(_events, (e) => !e || e
|
257
|
+
_.remove(_events, (e) => !e || e.once);
|
252
258
|
}
|
253
259
|
|
254
260
|
function onEvent({ name, id, callback, once, timeout }) {
|
@@ -279,51 +285,23 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
279
285
|
|
280
286
|
// name, id, callback
|
281
287
|
function offEvent(name) {
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
case "string":
|
288
|
-
if (Array.isArray(events[nameE])) {
|
289
|
-
//name
|
290
|
-
for (const eventElement of events[nameE]) {
|
291
|
-
if (eventElement.timeout) {
|
292
|
-
clearTimeout(eventElement.timeout);
|
293
|
-
}
|
294
|
-
}
|
295
|
-
events[nameE] = [];
|
296
|
-
} else {
|
297
|
-
//id
|
298
|
-
for (const eventsKey in events) {
|
299
|
-
if (!Array.isArray(events[eventsKey])) {
|
300
|
-
continue;
|
301
|
-
}
|
302
|
-
const index = events[eventsKey].findIndex((e) => e.id === nameE);
|
303
|
-
if (index > -1) {
|
304
|
-
if (events[eventsKey].timeout) {
|
305
|
-
clearTimeout(events[eventsKey].timeout);
|
306
|
-
}
|
307
|
-
events[eventsKey].splice(index, 1);
|
308
|
-
}
|
309
|
-
}
|
288
|
+
for (const [eventName, _events] of Object.entries(events)) {
|
289
|
+
if (eventName === name) {
|
290
|
+
for (const event of _events) {
|
291
|
+
if (event.timeout) {
|
292
|
+
clearTimeout(event.timeout);
|
310
293
|
}
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
if (events[eventsKey].timeout) {
|
321
|
-
clearTimeout(events[eventsKey].timeout);
|
322
|
-
}
|
323
|
-
events[eventsKey].splice(index, 1);
|
324
|
-
}
|
294
|
+
}
|
295
|
+
_events.length = 0;
|
296
|
+
} else {
|
297
|
+
const removedEvents = _.remove(_events, function (e) {
|
298
|
+
return Object.values(e).some((v) => v === name);
|
299
|
+
});
|
300
|
+
for (const removedEvent of removedEvents) {
|
301
|
+
if (removedEvent.timeout) {
|
302
|
+
clearTimeout(removedEvent.timeout);
|
325
303
|
}
|
326
|
-
|
304
|
+
}
|
327
305
|
}
|
328
306
|
}
|
329
307
|
}
|
@@ -342,7 +320,7 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
342
320
|
delete event.timeout;
|
343
321
|
}
|
344
322
|
}
|
345
|
-
events[name] =
|
323
|
+
events[name].length = 0;
|
346
324
|
}
|
347
325
|
onAnyCallbacks.length = 0;
|
348
326
|
}
|
@@ -429,6 +407,7 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
429
407
|
}
|
430
408
|
|
431
409
|
async function getPersonas(steamIDs) {
|
410
|
+
if (isLogOff) return [];
|
432
411
|
if (!steamIDs) return [];
|
433
412
|
if (!Array.isArray(steamIDs)) {
|
434
413
|
steamIDs = [steamIDs];
|
@@ -491,6 +470,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
491
470
|
}
|
492
471
|
|
493
472
|
async function getCookiesWait() {
|
473
|
+
if (isLogOff) {
|
474
|
+
return;
|
475
|
+
}
|
494
476
|
return (
|
495
477
|
getCookies() ||
|
496
478
|
new Promise((resolve) => {
|
@@ -507,6 +489,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
507
489
|
}
|
508
490
|
|
509
491
|
async function gamePlay() {
|
492
|
+
if (isLogOff) {
|
493
|
+
return;
|
494
|
+
}
|
510
495
|
return await gamesPlayed(730);
|
511
496
|
}
|
512
497
|
|
@@ -522,9 +507,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
522
507
|
|
523
508
|
async function updateAutoGamePlay() {
|
524
509
|
if (isAutoPlay) {
|
525
|
-
autoGamePlay();
|
510
|
+
await autoGamePlay();
|
526
511
|
} else {
|
527
|
-
offAutoGamePlay();
|
512
|
+
await offAutoGamePlay();
|
528
513
|
}
|
529
514
|
}
|
530
515
|
|
@@ -537,6 +522,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
537
522
|
* @returns {Promise.<Array>}
|
538
523
|
*/
|
539
524
|
async function partySearch({ prime = false, game_type = "Premier", rank, timeout = 5000 } = {}) {
|
525
|
+
if (isLogOff) {
|
526
|
+
return;
|
527
|
+
}
|
540
528
|
const gameTypeMap = {
|
541
529
|
Competitive: 8,
|
542
530
|
Wingman: 10,
|
@@ -588,6 +576,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
588
576
|
}
|
589
577
|
|
590
578
|
async function createLobby() {
|
579
|
+
if (isLogOff) {
|
580
|
+
return;
|
581
|
+
}
|
591
582
|
if (!steamClient.steamID) {
|
592
583
|
return;
|
593
584
|
}
|
@@ -639,6 +630,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
639
630
|
}
|
640
631
|
|
641
632
|
async function updateLobby(lobbyID) {
|
633
|
+
if (isLogOff) {
|
634
|
+
return;
|
635
|
+
}
|
642
636
|
if (!steamClient.steamID) {
|
643
637
|
return;
|
644
638
|
}
|
@@ -702,6 +696,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
702
696
|
}
|
703
697
|
|
704
698
|
async function invite2Lobby(lobbyID, steamId) {
|
699
|
+
if (isLogOff) {
|
700
|
+
return;
|
701
|
+
}
|
705
702
|
if (!steamClient.steamID) {
|
706
703
|
return;
|
707
704
|
}
|
@@ -735,6 +732,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
735
732
|
}
|
736
733
|
|
737
734
|
async function createThenInvite2Lobby(steamIds, onInvite) {
|
735
|
+
if (isLogOff) {
|
736
|
+
return;
|
737
|
+
}
|
738
738
|
if (!steamClient.steamID) {
|
739
739
|
return;
|
740
740
|
}
|
@@ -761,6 +761,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
761
761
|
}
|
762
762
|
|
763
763
|
async function getLobbyData(lobbyID) {
|
764
|
+
if (isLogOff) {
|
765
|
+
return;
|
766
|
+
}
|
764
767
|
if (!steamClient.steamID) {
|
765
768
|
return;
|
766
769
|
}
|
@@ -793,6 +796,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
793
796
|
}
|
794
797
|
|
795
798
|
async function joinLobby(lobbyID) {
|
799
|
+
if (isLogOff) {
|
800
|
+
return;
|
801
|
+
}
|
796
802
|
log("joinLobby", lobbyID); //SteamID.fromIndividualAccountID(lobbyId).accountid
|
797
803
|
|
798
804
|
steamClient._send(
|
@@ -829,6 +835,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
829
835
|
}
|
830
836
|
|
831
837
|
async function sendHello() {
|
838
|
+
if (isLogOff) {
|
839
|
+
return;
|
840
|
+
}
|
832
841
|
steamClient.sendToGC(AppID, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello, {}, Buffer.alloc(0));
|
833
842
|
// steamClient.sendToGC(AppID, ESteamProto.EGCBaseClientMsg.k_EMsgGCClientHello, {}, Buffer.alloc(0));
|
834
843
|
|
@@ -846,6 +855,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
846
855
|
}
|
847
856
|
|
848
857
|
async function requestCoPlays() {
|
858
|
+
if (isLogOff) {
|
859
|
+
return;
|
860
|
+
}
|
849
861
|
const gcEventId = uuidv4();
|
850
862
|
const response = await ensureLogin(
|
851
863
|
new Promise((resolve) => {
|
@@ -1807,6 +1819,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
1807
1819
|
}
|
1808
1820
|
|
1809
1821
|
function sendFriendTyping(steamId, callback) {
|
1822
|
+
if (isLogOff) {
|
1823
|
+
return;
|
1824
|
+
}
|
1810
1825
|
steamClient.chat.sendFriendTyping(steamId, callback);
|
1811
1826
|
}
|
1812
1827
|
|
@@ -1814,6 +1829,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
1814
1829
|
* usually take 400 -> 800 miliseconds
|
1815
1830
|
* */
|
1816
1831
|
async function getPlayersProfile(steamId) {
|
1832
|
+
if (isLogOff) {
|
1833
|
+
return;
|
1834
|
+
}
|
1817
1835
|
const accountid = new SteamID(steamId).accountid;
|
1818
1836
|
const gcEventId = uuidv4();
|
1819
1837
|
const result = await ensureLogin(
|
@@ -1841,6 +1859,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
1841
1859
|
}
|
1842
1860
|
|
1843
1861
|
async function checkPlayerPrimeStatus(steamId) {
|
1862
|
+
if (isLogOff) {
|
1863
|
+
return;
|
1864
|
+
}
|
1844
1865
|
const profile = await getPlayersProfile(steamId);
|
1845
1866
|
if (!profile) return false;
|
1846
1867
|
|
@@ -1972,6 +1993,11 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
1972
1993
|
*/
|
1973
1994
|
async function logOn(token) {
|
1974
1995
|
try {
|
1996
|
+
isLogOff = false;
|
1997
|
+
if (!steamClient) {
|
1998
|
+
steamClient = new NodeSteamUser();
|
1999
|
+
bindEvent();
|
2000
|
+
}
|
1975
2001
|
steamClient.logOn({
|
1976
2002
|
...token,
|
1977
2003
|
steamId: new SteamID(token.steamid),
|
@@ -2087,8 +2113,11 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2087
2113
|
}
|
2088
2114
|
|
2089
2115
|
async function logOff() {
|
2116
|
+
log("logOff");
|
2090
2117
|
isLogOff = true;
|
2091
2118
|
|
2119
|
+
MessageQueue.length = 0;
|
2120
|
+
|
2092
2121
|
callEvent(events.logOff);
|
2093
2122
|
events.logOff = [];
|
2094
2123
|
|
@@ -2101,44 +2130,54 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2101
2130
|
if (_cleanNodeSteamFriendTimeout) {
|
2102
2131
|
clearTimeout(_cleanNodeSteamFriendTimeout);
|
2103
2132
|
}
|
2104
|
-
steamClient.users = {};
|
2105
|
-
steamClient.myFriends = {};
|
2106
|
-
steamClient.licenses = [];
|
2107
2133
|
|
2108
2134
|
steamClient.logOff();
|
2109
2135
|
await sleep(5000);
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2136
|
+
|
2137
|
+
steamClient._connection?.end(true);
|
2138
|
+
|
2139
|
+
function cleanSteamClient(obj, key) {
|
2140
|
+
const value = obj[key];
|
2141
|
+
|
2142
|
+
try {
|
2143
|
+
delete obj[key];
|
2144
|
+
} catch (e) {
|
2145
|
+
return;
|
2146
|
+
}
|
2147
|
+
|
2148
|
+
if (!value) {
|
2149
|
+
return;
|
2150
|
+
}
|
2151
|
+
|
2152
|
+
if (typeof value !== "object") {
|
2153
|
+
return;
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
if (Array.isArray(value)) {
|
2157
|
+
value.length = 0;
|
2158
|
+
} else {
|
2159
|
+
const constructorName = Object.getPrototypeOf(value)?.constructor?.name;
|
2160
|
+
if (constructorName === "TLSSocket") {
|
2161
|
+
value.destroy?.();
|
2162
|
+
} else if (constructorName === "Timeout") {
|
2163
|
+
clearTimeout(value);
|
2164
|
+
} else if (constructorName === "SteamUser") {
|
2165
|
+
} else {
|
2166
|
+
for (const valuekey in value) {
|
2167
|
+
cleanSteamClient(value, valuekey);
|
2168
|
+
}
|
2169
|
+
}
|
2170
|
+
}
|
2171
|
+
}
|
2134
2172
|
|
2135
2173
|
for (const key in steamClient) {
|
2136
|
-
|
2174
|
+
cleanSteamClient(steamClient, key);
|
2137
2175
|
}
|
2176
|
+
steamClient = null;
|
2138
2177
|
}
|
2139
2178
|
|
2140
2179
|
async function init() {
|
2141
|
-
|
2180
|
+
isLogOff = false;
|
2142
2181
|
const logged = await login();
|
2143
2182
|
if (logged) {
|
2144
2183
|
steamClient._handlerManager.add(ESteamProto.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
|
@@ -2153,6 +2192,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2153
2192
|
}
|
2154
2193
|
|
2155
2194
|
function partyRegister() {
|
2195
|
+
if (isLogOff) {
|
2196
|
+
return;
|
2197
|
+
}
|
2156
2198
|
if (prime === null) {
|
2157
2199
|
_partyRegister(true);
|
2158
2200
|
_partyRegister(false);
|
@@ -2162,6 +2204,10 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2162
2204
|
}
|
2163
2205
|
|
2164
2206
|
function _partyRegister(prime) {
|
2207
|
+
if (isLogOff) {
|
2208
|
+
return;
|
2209
|
+
}
|
2210
|
+
|
2165
2211
|
log("partyRegister", prime);
|
2166
2212
|
lastTimePartyRegister = Date.now();
|
2167
2213
|
steamClient.sendToGC(
|
@@ -2183,6 +2229,10 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2183
2229
|
const MessageQueue = [];
|
2184
2230
|
|
2185
2231
|
async function _execMessageQueue() {
|
2232
|
+
if (isLogOff) {
|
2233
|
+
return;
|
2234
|
+
}
|
2235
|
+
|
2186
2236
|
if (isSendingFriendMessages) {
|
2187
2237
|
return;
|
2188
2238
|
}
|
@@ -2201,6 +2251,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2201
2251
|
async function _sendFriendMessage(steamId, message) {
|
2202
2252
|
let result = null;
|
2203
2253
|
for (let i = 0; i < 10; i++) {
|
2254
|
+
if (isLogOff) {
|
2255
|
+
return;
|
2256
|
+
}
|
2204
2257
|
result = await new Promise((resolve) => {
|
2205
2258
|
steamClient.chat.sendFriendMessage(steamId, message, undefined, function (...arg) {
|
2206
2259
|
resolve(arg);
|
@@ -2218,6 +2271,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2218
2271
|
}
|
2219
2272
|
|
2220
2273
|
async function sendFriendMessage(steamId, message) {
|
2274
|
+
if (isLogOff) {
|
2275
|
+
return;
|
2276
|
+
}
|
2221
2277
|
return new Promise((resolve) => {
|
2222
2278
|
MessageQueue.push({ steamId, message, callback: resolve });
|
2223
2279
|
_execMessageQueue();
|
@@ -2323,6 +2379,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2323
2379
|
}
|
2324
2380
|
|
2325
2381
|
function doFakeGameScore() {
|
2382
|
+
if (isLogOff) {
|
2383
|
+
return;
|
2384
|
+
}
|
2326
2385
|
const maxRound = Math.random() > 0.7 ? 16 : 12;
|
2327
2386
|
const maps = ["cs_agency", "cs_assault", "cs_italy", "cs_militia", "cs_office", "de_ancient", "de_anubis", "de_bank", "de_boyard", "de_cache", "de_canals", "de_cbble", "de_chalice", "de_dust2", "de_inferno", "de_lake", "de_mirage", "de_nuke", "de_overpass", "de_safehouse", "de_sugarcane", "de_train", "de_tuscan", "de_vertigo", "de_thera", "de_mills", "de_memento", "de_assembly", "training1"];
|
2328
2387
|
|
@@ -2404,6 +2463,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2404
2463
|
}
|
2405
2464
|
|
2406
2465
|
async function gamesPlayed(apps) {
|
2466
|
+
if (isLogOff) {
|
2467
|
+
return;
|
2468
|
+
}
|
2407
2469
|
if (!Array.isArray(apps)) {
|
2408
2470
|
apps = [apps];
|
2409
2471
|
}
|
@@ -2441,6 +2503,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2441
2503
|
}
|
2442
2504
|
|
2443
2505
|
function getFriendsList() {
|
2506
|
+
if (isLogOff) {
|
2507
|
+
return;
|
2508
|
+
}
|
2444
2509
|
const methodName = "FriendsList.GetFriendsList#1";
|
2445
2510
|
const { users, myFriends } = steamClient; //object
|
2446
2511
|
/*
|
@@ -2480,6 +2545,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2480
2545
|
}
|
2481
2546
|
|
2482
2547
|
async function getUserOwnedApps(steamId = steamClient.steamID) {
|
2548
|
+
if (isLogOff) {
|
2549
|
+
return;
|
2550
|
+
}
|
2483
2551
|
if (!steamId) {
|
2484
2552
|
return [];
|
2485
2553
|
}
|
@@ -2536,6 +2604,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2536
2604
|
}
|
2537
2605
|
|
2538
2606
|
async function requestJoinFriendData(token, version) {
|
2607
|
+
if (isLogOff) {
|
2608
|
+
return;
|
2609
|
+
}
|
2539
2610
|
if (!steamClient.steamID) {
|
2540
2611
|
return;
|
2541
2612
|
}
|
@@ -2578,6 +2649,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2578
2649
|
}
|
2579
2650
|
|
2580
2651
|
function redeemFreeReward(itemIds, generation_time) {
|
2652
|
+
if (isLogOff) {
|
2653
|
+
return;
|
2654
|
+
}
|
2581
2655
|
console.log(`Sent message to GC: AppID ${AppID}, MessageType ${ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward}`);
|
2582
2656
|
|
2583
2657
|
const encodedMessages = new SteamProto(SteamProtoType.CMsgGCCstrike15_v2_ClientRedeemFreeReward).protoEncode({
|
@@ -2598,6 +2672,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2598
2672
|
}
|
2599
2673
|
|
2600
2674
|
function requestRankingInfo() {
|
2675
|
+
if (isLogOff) {
|
2676
|
+
return;
|
2677
|
+
}
|
2601
2678
|
return new Promise((resolve) => {
|
2602
2679
|
const timeout = setTimeout(function () {
|
2603
2680
|
resolve();
|
@@ -2633,6 +2710,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2633
2710
|
}
|
2634
2711
|
|
2635
2712
|
function acknowledgePenalty() {
|
2713
|
+
if (isLogOff) {
|
2714
|
+
return;
|
2715
|
+
}
|
2636
2716
|
steamClient.sendToGC(
|
2637
2717
|
730,
|
2638
2718
|
ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_AcknowledgePenalty,
|
@@ -2644,6 +2724,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2644
2724
|
}
|
2645
2725
|
|
2646
2726
|
async function ensureLogin(promise) {
|
2727
|
+
if (isLogOff) {
|
2728
|
+
return null;
|
2729
|
+
}
|
2647
2730
|
const logOffEventId = uuidv4();
|
2648
2731
|
const result = await Promise.race([
|
2649
2732
|
new Promise((resolve) => {
|
@@ -2697,6 +2780,9 @@ function SteamClient({ username, cookie, clientJsToken, isAutoRequestFreeLicense
|
|
2697
2780
|
getPersonaName,
|
2698
2781
|
async getPlayersProfile(steamId, retry = 3) {
|
2699
2782
|
for (let i = 0; i < retry; i++) {
|
2783
|
+
if (isLogOff) {
|
2784
|
+
return;
|
2785
|
+
}
|
2700
2786
|
const profile = await getPlayersProfile(steamId);
|
2701
2787
|
if (profile) {
|
2702
2788
|
return profile;
|