steamutils 1.4.34 → 1.4.35
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +32 -23
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -76,7 +76,6 @@ export const LOCS = {
|
|
76
76
|
|
77
77
|
const AppID = 730;
|
78
78
|
export let CSGO_VER = 13960;
|
79
|
-
export const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, "free_packages.json"))).packages;
|
80
79
|
|
81
80
|
SteamUser.getAppVersion(AppID).then(function (ver) {
|
82
81
|
CSGO_VER = ver;
|
@@ -92,7 +91,6 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
92
91
|
let isLogOff = false;
|
93
92
|
let playingBlocked = null;
|
94
93
|
const richPresence = {};
|
95
|
-
let sendMessageTimestamp = 0;
|
96
94
|
let lastTimePartyRegister = 0;
|
97
95
|
let lastTimePartySearch = 0;
|
98
96
|
const ownedApps = [];
|
@@ -406,7 +404,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
406
404
|
game_type: game_type === "Competitive" ? 8 : 10,
|
407
405
|
}),
|
408
406
|
);
|
409
|
-
lastTimePartySearch =
|
407
|
+
lastTimePartySearch = Date.now();
|
410
408
|
pushGCCallback("partySearch", resolve, timeout);
|
411
409
|
});
|
412
410
|
if (Array.isArray(players) && players.length) {
|
@@ -451,7 +449,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
451
449
|
const result = protoDecode(Protos.csgo.CMsgClientMMSCreateLobbyResponse, payload.toBuffer());
|
452
450
|
const steam_id_lobby = result.steam_id_lobby.toString();
|
453
451
|
currentLobby.lobbyID = steam_id_lobby;
|
454
|
-
currentLobby.timestamp =
|
452
|
+
currentLobby.timestamp = Date.now();
|
455
453
|
resolve(steam_id_lobby);
|
456
454
|
},
|
457
455
|
);
|
@@ -524,7 +522,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
524
522
|
const result = protoDecode(Protos.csgo.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer());
|
525
523
|
const steam_id_lobby = result.steam_id_lobby.toString();
|
526
524
|
currentLobby.lobbyID = steam_id_lobby;
|
527
|
-
currentLobby.timestamp =
|
525
|
+
currentLobby.timestamp = Date.now();
|
528
526
|
resolve(steam_id_lobby);
|
529
527
|
},
|
530
528
|
);
|
@@ -579,7 +577,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
579
577
|
}
|
580
578
|
|
581
579
|
let lobbyID = null;
|
582
|
-
if (currentLobby.lobbyID && currentLobby.timestamp >
|
580
|
+
if (currentLobby.lobbyID && currentLobby.timestamp > Date.now() - 30000) {
|
583
581
|
//30 seconds
|
584
582
|
lobbyID = currentLobby.lobbyID;
|
585
583
|
} else {
|
@@ -1818,7 +1816,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1818
1816
|
|
1819
1817
|
function _partyRegister(prime) {
|
1820
1818
|
log("partyRegister", prime);
|
1821
|
-
lastTimePartyRegister =
|
1819
|
+
lastTimePartyRegister = Date.now();
|
1822
1820
|
steamClient.sendToGC(
|
1823
1821
|
730,
|
1824
1822
|
Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Register,
|
@@ -1835,37 +1833,48 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
|
|
1835
1833
|
);
|
1836
1834
|
}
|
1837
1835
|
|
1838
|
-
|
1839
|
-
while (sendMessageTimestamp && new Date().getTime() - sendMessageTimestamp < 2000) {
|
1840
|
-
await sleep(1000);
|
1841
|
-
}
|
1836
|
+
const MessageQueue = [];
|
1842
1837
|
|
1843
|
-
|
1844
|
-
|
1838
|
+
async function _execMessageQueue() {
|
1839
|
+
if (isSendingFriendMessages) {
|
1840
|
+
return;
|
1845
1841
|
}
|
1842
|
+
while (MessageQueue.length) {
|
1843
|
+
isSendingFriendMessages = true;
|
1844
|
+
const item = MessageQueue.shift();
|
1845
|
+
const result = await _sendFriendMessage(item.steamId, item.message);
|
1846
|
+
item.callback(result);
|
1847
|
+
if (MessageQueue.length) {
|
1848
|
+
await sleep(1000);
|
1849
|
+
}
|
1850
|
+
}
|
1851
|
+
isSendingFriendMessages = false;
|
1852
|
+
}
|
1846
1853
|
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
const result = await new Promise((resolve) => {
|
1854
|
+
async function _sendFriendMessage(steamId, message) {
|
1855
|
+
let result = null;
|
1856
|
+
for (let i = 0; i < 10; i++) {
|
1857
|
+
result = await new Promise((resolve) => {
|
1852
1858
|
steamClient.chat.sendFriendMessage(steamId, message, undefined, function (...arg) {
|
1853
|
-
sendMessageTimestamp = new Date().getTime();
|
1854
1859
|
resolve(arg);
|
1855
1860
|
});
|
1856
1861
|
});
|
1857
|
-
|
1858
1862
|
if (result?.[1]?.server_timestamp) {
|
1859
|
-
isSendingFriendMessages = false;
|
1860
1863
|
return result?.[1];
|
1861
1864
|
} else if (result?.[0]?.message?.includes?.("RateLimitExceeded")) {
|
1862
1865
|
await sleep(5000);
|
1863
1866
|
} else {
|
1864
|
-
isSendingFriendMessages = false;
|
1865
1867
|
return result;
|
1866
1868
|
}
|
1867
1869
|
}
|
1868
|
-
|
1870
|
+
return result;
|
1871
|
+
}
|
1872
|
+
|
1873
|
+
async function sendFriendMessage(steamId, message) {
|
1874
|
+
return new Promise((resolve) => {
|
1875
|
+
MessageQueue.push({ steamId, message, callback: resolve });
|
1876
|
+
_execMessageQueue();
|
1877
|
+
});
|
1869
1878
|
}
|
1870
1879
|
|
1871
1880
|
async function autoRequestFreeLicense(shouldLog = false, max = 10) {
|