steamutils 1.3.37 → 1.3.39
Sign up to get free protection for your applications and to get access to all the features.
- package/SteamClient.js +78 -12
- package/index.js +5 -5
- package/package.json +2 -2
package/SteamClient.js
CHANGED
@@ -111,6 +111,11 @@ function SteamClient({
|
|
111
111
|
const ownedApps = []
|
112
112
|
let logOffEvent = null
|
113
113
|
|
114
|
+
const currentLobby = {
|
115
|
+
lobbyID: null,
|
116
|
+
timestamp: 0
|
117
|
+
}
|
118
|
+
|
114
119
|
const onAnyCallbacks = []
|
115
120
|
|
116
121
|
const events = {
|
@@ -467,7 +472,10 @@ function SteamClient({
|
|
467
472
|
}), function (payload) {
|
468
473
|
clearTimeout(timeout)
|
469
474
|
const result = protoDecode(Protos.csgo.CMsgClientMMSCreateLobbyResponse, payload.toBuffer())
|
470
|
-
|
475
|
+
const steam_id_lobby = result.steam_id_lobby.toString();
|
476
|
+
currentLobby.lobbyID = steam_id_lobby
|
477
|
+
currentLobby.timestamp = new Date().getTime()
|
478
|
+
resolve(steam_id_lobby)
|
471
479
|
}
|
472
480
|
);
|
473
481
|
})
|
@@ -532,7 +540,10 @@ function SteamClient({
|
|
532
540
|
function (payload) {
|
533
541
|
clearTimeout(timeout)
|
534
542
|
const result = protoDecode(Protos.csgo.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer())
|
535
|
-
|
543
|
+
const steam_id_lobby = result.steam_id_lobby.toString();
|
544
|
+
currentLobby.lobbyID = steam_id_lobby
|
545
|
+
currentLobby.timestamp = new Date().getTime()
|
546
|
+
resolve(steam_id_lobby)
|
536
547
|
}
|
537
548
|
);
|
538
549
|
})
|
@@ -575,6 +586,28 @@ function SteamClient({
|
|
575
586
|
// })
|
576
587
|
}
|
577
588
|
|
589
|
+
async function createThenInvite2Lobby(steamIds) {
|
590
|
+
if (!steamClient.steamID) {
|
591
|
+
return
|
592
|
+
}
|
593
|
+
|
594
|
+
if(!Array.isArray(steamIds)){
|
595
|
+
steamIds = [steamIds]
|
596
|
+
}
|
597
|
+
|
598
|
+
let lobbyID = null
|
599
|
+
if (currentLobby.lobbyID && currentLobby.timestamp > new Date().getTime() - 30000) {//30 seconds
|
600
|
+
lobbyID = currentLobby.lobbyID
|
601
|
+
} else {
|
602
|
+
lobbyID = await createLobby();
|
603
|
+
lobbyID = await updateLobby(lobbyID)
|
604
|
+
}
|
605
|
+
|
606
|
+
for (const steamId of steamIds) {
|
607
|
+
await invite2Lobby(lobbyID, steamId)
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
578
611
|
|
579
612
|
async function getLobbyData(lobbyID) {
|
580
613
|
if (!steamClient.steamID) {
|
@@ -611,13 +644,38 @@ function SteamClient({
|
|
611
644
|
|
612
645
|
async function joinLobby(lobbyID) {
|
613
646
|
log("joinLobby", lobbyID);//SteamID.fromIndividualAccountID(lobbyId).accountid
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
647
|
+
|
648
|
+
steamClient._send(
|
649
|
+
{
|
650
|
+
msg: Protos.csgo.EMsg.k_EMsgClientMMSJoinLobby,
|
651
|
+
proto: {
|
652
|
+
steamid: steamClient.steamID.getSteamID64(),
|
653
|
+
routing_appid: 730
|
654
|
+
}
|
655
|
+
},//CMsgClientMMSUserJoinedLobby CMsgClientMMSJoinLobby
|
656
|
+
protoEncode(Protos.csgo.CMsgClientMMSJoinLobby, {
|
657
|
+
app_id: 730,
|
658
|
+
steam_id_lobby: lobbyID,
|
659
|
+
persona_name: steamClient.accountInfo.name,
|
660
|
+
}),
|
661
|
+
function (payload) {
|
662
|
+
const result = protoDecode(Protos.csgo.CMsgClientMMSJoinLobbyResponse, payload.toBuffer())
|
663
|
+
result.steam_id_lobby = result.steam_id_lobby.toString()
|
664
|
+
result.steam_id_owner = result.steam_id_owner.toString()
|
665
|
+
console.log(result);
|
666
|
+
const resultExample = {
|
667
|
+
members: [],
|
668
|
+
app_id: 730,
|
669
|
+
steam_id_lobby: "3641224920",
|
670
|
+
chat_room_enter_response: 2,
|
671
|
+
max_members: 0,
|
672
|
+
lobby_type: 0,
|
673
|
+
lobby_flags: 0,
|
674
|
+
steam_id_owner: "0",
|
675
|
+
metadata: null//Buffer
|
676
|
+
}
|
677
|
+
}
|
678
|
+
)
|
621
679
|
}
|
622
680
|
|
623
681
|
async function sendHello() {
|
@@ -1632,8 +1690,12 @@ function SteamClient({
|
|
1632
1690
|
log(reconnect ? 'reconnect with cookie' : 'login with cookie')
|
1633
1691
|
const _clientJsToken = await new SteamUtils(typeof cookie === "function" ? await cookie() : cookie).getClientJsToken()
|
1634
1692
|
if (_clientJsToken?.logged_in === true) {
|
1635
|
-
|
1636
|
-
|
1693
|
+
try {
|
1694
|
+
await steamClient.logOn(_clientJsToken)
|
1695
|
+
return true
|
1696
|
+
} catch (e) {
|
1697
|
+
return false
|
1698
|
+
}
|
1637
1699
|
} else {
|
1638
1700
|
return false
|
1639
1701
|
}
|
@@ -2006,6 +2068,7 @@ function SteamClient({
|
|
2006
2068
|
invite2Lobby,
|
2007
2069
|
createLobby,
|
2008
2070
|
updateLobby,
|
2071
|
+
createThenInvite2Lobby,
|
2009
2072
|
joinLobby,
|
2010
2073
|
getLobbyData,
|
2011
2074
|
partyRegister,
|
@@ -2189,7 +2252,10 @@ function SteamClient({
|
|
2189
2252
|
steamClient.uploadRichPresence(appid, richPresence)
|
2190
2253
|
},
|
2191
2254
|
getUserOwnedApps,
|
2192
|
-
getPlayingAppIds
|
2255
|
+
getPlayingAppIds,
|
2256
|
+
getCurrentLobby(){
|
2257
|
+
return currentLobby
|
2258
|
+
}
|
2193
2259
|
}
|
2194
2260
|
}
|
2195
2261
|
|
package/index.js
CHANGED
@@ -18,7 +18,7 @@ import fs from "fs";
|
|
18
18
|
import FormData from "form-data";
|
19
19
|
import {StringUtils} from "alpha-common-utils/index.js";
|
20
20
|
import * as https from "https";
|
21
|
-
import
|
21
|
+
import Jimp from "jimp";
|
22
22
|
import path from "path";
|
23
23
|
|
24
24
|
const MAX_RETRY = 10
|
@@ -6245,7 +6245,7 @@ class SteamUser {
|
|
6245
6245
|
}
|
6246
6246
|
|
6247
6247
|
async beginFileUpload(filePath) {
|
6248
|
-
const
|
6248
|
+
const image = await Jimp.read(filePath)
|
6249
6249
|
const stats = fs.statSync(filePath)
|
6250
6250
|
|
6251
6251
|
let sha1 = "";
|
@@ -6258,9 +6258,9 @@ class SteamUser {
|
|
6258
6258
|
file_size: stats.size,
|
6259
6259
|
file_name: path.basename(filePath),
|
6260
6260
|
file_sha: sha1,
|
6261
|
-
file_image_width:
|
6262
|
-
file_image_height:
|
6263
|
-
file_type:
|
6261
|
+
file_image_width: image.getWidth(),
|
6262
|
+
file_image_height: image.getHeight(),
|
6263
|
+
file_type: image.getMIME(),
|
6264
6264
|
sessionid: this.getSessionid()
|
6265
6265
|
}
|
6266
6266
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "steamutils",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.39",
|
4
4
|
"main": "index.js",
|
5
5
|
"dependencies": {
|
6
6
|
"alpha-common-utils": "^1.0.5",
|
@@ -10,11 +10,11 @@
|
|
10
10
|
"crypto-js": "^4.2.0",
|
11
11
|
"csgo-friendcode": "^3.0.3",
|
12
12
|
"form-data": "^4.0.0",
|
13
|
+
"jimp": "^0.22.10",
|
13
14
|
"lodash": "^4.17.21",
|
14
15
|
"moment": "^2.30.1",
|
15
16
|
"moment-timezone": "^0.5.44",
|
16
17
|
"node-bignumber": "^1.2.2",
|
17
|
-
"sharp": "^0.33.2",
|
18
18
|
"steam-session": "^1.7.2",
|
19
19
|
"steam-user": "^5.0.7",
|
20
20
|
"steamcommunity": "^3.48.2",
|