steamutils 1.0.43 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/steamutils.iml +1 -1
- package/.idea/vcs.xml +1 -1
- package/SteamClient.js +58 -23
- package/package.json +1 -1
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
package/.idea/steamutils.iml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
<module type="WEB_MODULE" version="4">
|
3
3
|
<component name="NewModuleRootManager">
|
4
4
|
<content url="file://$MODULE_DIR$">
|
5
|
-
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
6
5
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
7
7
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
8
8
|
</content>
|
9
9
|
<orderEntry type="inheritedJdk" />
|
package/.idea/vcs.xml
CHANGED
package/SteamClient.js
CHANGED
@@ -95,10 +95,33 @@ function SteamClient({
|
|
95
95
|
|
96
96
|
const events = {
|
97
97
|
loggedOn: [],
|
98
|
+
csgoOnline: [],
|
98
99
|
webSession: [],
|
99
100
|
friendMessage: [],
|
100
101
|
friendTyping: [],
|
101
102
|
}
|
103
|
+
function callEvent(_events, data) {
|
104
|
+
_events.forEach((e) => {
|
105
|
+
e.callback?.(data)
|
106
|
+
e.timeout && clearTimeout(e.timeout)
|
107
|
+
delete e.timeout
|
108
|
+
if (e.once) {
|
109
|
+
delete e.callback
|
110
|
+
}
|
111
|
+
})
|
112
|
+
_.remove(_events, e => e.once)
|
113
|
+
}
|
114
|
+
function onEvent(name, callback, once, timeout) {
|
115
|
+
if (!events[name]) {
|
116
|
+
events[name] = []
|
117
|
+
}
|
118
|
+
const t = timeout ? setTimeout(callback, timeout) : null
|
119
|
+
events[name].push({
|
120
|
+
once,
|
121
|
+
callback,
|
122
|
+
timeout: t,
|
123
|
+
})
|
124
|
+
}
|
102
125
|
|
103
126
|
const intervals = {}
|
104
127
|
|
@@ -255,7 +278,7 @@ function SteamClient({
|
|
255
278
|
steamClient.on('webSession', (sessionID, cookies) => {
|
256
279
|
const webSession = {sessionID, cookies};
|
257
280
|
steamClient.webSession = webSession
|
258
|
-
events.webSession
|
281
|
+
callEvent(events.webSession, webSession)
|
259
282
|
})
|
260
283
|
|
261
284
|
steamClient.on('receivedFromGC', async (appid, msgType, payload) => {
|
@@ -307,9 +330,13 @@ function SteamClient({
|
|
307
330
|
}
|
308
331
|
break
|
309
332
|
}
|
333
|
+
default: {
|
334
|
+
console.log("cache_object.type_id", cache_object.type_id);
|
335
|
+
}
|
310
336
|
}
|
311
337
|
}
|
312
338
|
}
|
339
|
+
callEvent(events.csgoOnline)
|
313
340
|
break
|
314
341
|
}
|
315
342
|
case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate: {
|
@@ -506,7 +533,6 @@ function SteamClient({
|
|
506
533
|
player_cur_xp: 327682846,
|
507
534
|
player_xp_bonus_flags: 0
|
508
535
|
}]
|
509
|
-
console.log(data);
|
510
536
|
|
511
537
|
const accountid = data?.[0]?.account_id
|
512
538
|
const cb = getPlayersProfileCallback[accountid]
|
@@ -575,7 +601,7 @@ function SteamClient({
|
|
575
601
|
console.log(`app ${appid} launched on account ${getAccountInfoName()}`)
|
576
602
|
await sendHello()
|
577
603
|
|
578
|
-
events.loggedOn
|
604
|
+
callEvent(events.loggedOn)
|
579
605
|
})
|
580
606
|
|
581
607
|
steamClient.on('friendMessage', async (user, message) => {
|
@@ -584,26 +610,26 @@ function SteamClient({
|
|
584
610
|
const player_name = personas[sid64]?.player_name || ''
|
585
611
|
console.log('friendMessage', sid64, message);
|
586
612
|
|
587
|
-
if ([`
|
588
|
-
|
589
|
-
events.friendMessage.forEach(e => e?.({
|
613
|
+
if ([`Inited you to play a game!`, `Đã mời bạn chơi một trò chơi!`].includes(message)) {
|
614
|
+
callEvent(events.friendMessage, {
|
590
615
|
player_name,
|
591
616
|
message,
|
592
617
|
invite: true,
|
593
618
|
sid64,
|
594
|
-
|
595
|
-
}
|
619
|
+
})
|
596
620
|
} else {
|
597
|
-
events.friendMessage
|
621
|
+
callEvent(events.friendMessage, {
|
598
622
|
message,
|
599
623
|
player_name,
|
600
624
|
sid64,
|
601
|
-
})
|
625
|
+
})
|
602
626
|
}
|
603
627
|
});
|
604
628
|
|
605
629
|
steamClient.on('friendTyping', async function (steamID, message) {
|
606
|
-
events.friendTyping
|
630
|
+
callEvent(events.friendTyping, {
|
631
|
+
steamID, message
|
632
|
+
})
|
607
633
|
});
|
608
634
|
}
|
609
635
|
|
@@ -625,6 +651,20 @@ function SteamClient({
|
|
625
651
|
})
|
626
652
|
}
|
627
653
|
|
654
|
+
async function checkPlayerPrimeStatus(accountid) {
|
655
|
+
const profile = await getPlayersProfile(accountid)
|
656
|
+
if(!profile) return false
|
657
|
+
|
658
|
+
if(profile.ranking?.account_id){
|
659
|
+
return true
|
660
|
+
}
|
661
|
+
|
662
|
+
if(profile.player_level || profile.player_cur_xp){
|
663
|
+
return true
|
664
|
+
}
|
665
|
+
return false
|
666
|
+
}
|
667
|
+
|
628
668
|
async function getNewCookie(cookie) {
|
629
669
|
let response = (await axios.request({
|
630
670
|
url: 'https://store.steampowered.com/', headers: {
|
@@ -737,10 +777,11 @@ function SteamClient({
|
|
737
777
|
const steamUtils = new SteamUtils(getCookie())
|
738
778
|
|
739
779
|
const ownedAppsCount = log ? ((await steamUtils.getDynamicStoreUserData())?.rgOwnedApps?.length || 0) : 0
|
740
|
-
let recommendedApps = _.shuffle((await steamUtils.getDynamicStoreUserData())?.rgRecommendedApps || [])
|
741
|
-
if (!recommendedApps
|
780
|
+
let recommendedApps = Math.random() > 0.5 ? _.shuffle((await steamUtils.getDynamicStoreUserData())?.rgRecommendedApps || []) : []
|
781
|
+
if (!recommendedApps?.length) {
|
742
782
|
recommendedApps = (await axios.request({url: 'https://raw.githubusercontent.com/5x/easy-steam-free-packages/master/src/script/packages_db.json'}))?.data?.packages || []
|
743
783
|
}
|
784
|
+
|
744
785
|
if (max) {
|
745
786
|
recommendedApps.length = Math.min(recommendedApps.length, max)
|
746
787
|
}
|
@@ -794,15 +835,7 @@ function SteamClient({
|
|
794
835
|
getLogOnDetails() {
|
795
836
|
return steamClient?._logOnDetails
|
796
837
|
},
|
797
|
-
onEvent
|
798
|
-
if (!events[name]) {
|
799
|
-
events[name] = []
|
800
|
-
}
|
801
|
-
events[name].push(cb)
|
802
|
-
},
|
803
|
-
onEventLoggedOn(cb) {
|
804
|
-
events.loggedOn.push(cb)
|
805
|
-
},
|
838
|
+
onEvent,
|
806
839
|
setPersona(state, name) {
|
807
840
|
steamClient.setPersona(state, name)
|
808
841
|
},
|
@@ -825,7 +858,9 @@ function SteamClient({
|
|
825
858
|
await sleep(2000)
|
826
859
|
steamClient.setPersona(SteamUser.EPersonaState.LookingToPlay)
|
827
860
|
sendHello()
|
828
|
-
}
|
861
|
+
},
|
862
|
+
sendHello,
|
863
|
+
checkPlayerPrimeStatus,
|
829
864
|
}
|
830
865
|
}
|
831
866
|
|
package/package.json
CHANGED