steamutils 1.2.86 → 1.2.88
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/SteamClient.js +198 -166
- package/index.js +25 -14
- package/package.json +1 -1
package/SteamClient.js
CHANGED
|
@@ -78,9 +78,9 @@ const appid = 730
|
|
|
78
78
|
export let CSGO_VER = 13960
|
|
79
79
|
const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, 'free_packages.json'))).packages
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
SteamUtils.getAppVersion(appid).then(function (ver) {
|
|
82
|
+
CSGO_VER = ver
|
|
83
|
+
})
|
|
84
84
|
|
|
85
85
|
const PersonasCache = []
|
|
86
86
|
|
|
@@ -105,7 +105,7 @@ function SteamClient({
|
|
|
105
105
|
let sendMessageTimestamp = 0
|
|
106
106
|
let lastTimePartyRegister = 0
|
|
107
107
|
let lastTimePartySearch = 0
|
|
108
|
-
|
|
108
|
+
const appsPlayed = []
|
|
109
109
|
|
|
110
110
|
const onAnyCallbacks = []
|
|
111
111
|
|
|
@@ -373,9 +373,9 @@ function SteamClient({
|
|
|
373
373
|
prime = false,
|
|
374
374
|
game_type = 'Competitive',
|
|
375
375
|
rank = 'Silver Elite',
|
|
376
|
-
timeout =
|
|
376
|
+
timeout = 5000,
|
|
377
377
|
} = {}) {
|
|
378
|
-
|
|
378
|
+
const players = await new Promise(resolve => {
|
|
379
379
|
steamClient.sendToGC(appid, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search, {}, protoEncode(Protos.csgo.CMsgGCCStrike15_v2_Party_Search, {
|
|
380
380
|
ver: CSGO_VER,
|
|
381
381
|
apr: prime ? 1 : 0,
|
|
@@ -387,6 +387,17 @@ function SteamClient({
|
|
|
387
387
|
lastTimePartySearch = new Date().getTime()
|
|
388
388
|
pushGCCallback('partySearch', resolve, timeout)
|
|
389
389
|
})
|
|
390
|
+
if (Array.isArray(players) && players.length) {
|
|
391
|
+
const personas = await getPersonas(players.map(p => p.steamId))
|
|
392
|
+
for (const player of players) {
|
|
393
|
+
const persona = personas.find(p => p.id == player.steamId)
|
|
394
|
+
if (persona) {
|
|
395
|
+
player.player_name = persona.player_name
|
|
396
|
+
player.avatar_hash = persona.avatar_hash
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return players
|
|
390
401
|
}
|
|
391
402
|
|
|
392
403
|
async function createLobby() {
|
|
@@ -568,13 +579,13 @@ function SteamClient({
|
|
|
568
579
|
const result = protoDecode(Protos.csgo.CSOPersonaDataPublic, object_data);
|
|
569
580
|
obj.PersonaDataPublic = result
|
|
570
581
|
const example = {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
582
|
+
player_level: 4,
|
|
583
|
+
commendation: {
|
|
584
|
+
cmd_friendly: 149,
|
|
585
|
+
cmd_teaching: 108,
|
|
586
|
+
cmd_leader: 115
|
|
576
587
|
},
|
|
577
|
-
|
|
588
|
+
elevated_state: true
|
|
578
589
|
}
|
|
579
590
|
break
|
|
580
591
|
}
|
|
@@ -585,11 +596,11 @@ function SteamClient({
|
|
|
585
596
|
case 7: {
|
|
586
597
|
const CSOEconGameAccountClient = protoDecode(Protos.csgo.CSOEconGameAccountClient, object_data);
|
|
587
598
|
const CSOEconGameAccountClientExample = {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
599
|
+
additional_backpack_slots: 0,
|
|
600
|
+
bonus_xp_timestamp_refresh: 1688518800,//Wednesday 1:00:00 AM every week
|
|
601
|
+
bonus_xp_usedflags: 19,
|
|
602
|
+
elevated_state: 5,
|
|
603
|
+
elevated_timestamp: 5
|
|
593
604
|
} //1688518800
|
|
594
605
|
if ((CSOEconGameAccountClient.bonus_xp_usedflags & 16) != 0) { // EXPBonusFlag::PrestigeEarned
|
|
595
606
|
prime = true
|
|
@@ -637,10 +648,10 @@ function SteamClient({
|
|
|
637
648
|
case 43: {
|
|
638
649
|
const result = protoDecode(Protos.csgo.CSOEconDefaultEquippedDefinitionInstanceClient, object_data);
|
|
639
650
|
const example = {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
651
|
+
account_id: 1080136620,
|
|
652
|
+
item_definition: 61,
|
|
653
|
+
class_id: 3,
|
|
654
|
+
slot_id: 2
|
|
644
655
|
}
|
|
645
656
|
break
|
|
646
657
|
}
|
|
@@ -811,73 +822,68 @@ function SteamClient({
|
|
|
811
822
|
const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_SearchResults, payload)
|
|
812
823
|
const entries = _.uniqBy(result.entries, 'id')
|
|
813
824
|
//{
|
|
814
|
-
//
|
|
815
|
-
//
|
|
816
|
-
//
|
|
817
|
-
//
|
|
818
|
-
//
|
|
819
|
-
//
|
|
820
|
-
//
|
|
825
|
+
// id: 144900402,
|
|
826
|
+
// grp: 0,
|
|
827
|
+
// game_type: 8,
|
|
828
|
+
// apr: 1,
|
|
829
|
+
// ark: 17,
|
|
830
|
+
// loc: 20041,
|
|
831
|
+
// accountid: 0
|
|
821
832
|
// }
|
|
822
833
|
|
|
823
|
-
const players = []
|
|
824
834
|
|
|
825
|
-
const steamIDs = entries
|
|
826
|
-
.map(p => SteamID.fromIndividualAccountID(p.id).getSteamID64())
|
|
827
|
-
const personas = await getPersonas(steamIDs)
|
|
828
835
|
//{
|
|
829
|
-
//
|
|
830
|
-
//
|
|
831
|
-
//
|
|
832
|
-
//
|
|
833
|
-
//
|
|
834
|
-
//
|
|
835
|
-
//
|
|
836
|
-
//
|
|
837
|
-
//
|
|
838
|
-
//
|
|
839
|
-
//
|
|
840
|
-
//
|
|
841
|
-
//
|
|
842
|
-
//
|
|
843
|
-
//
|
|
844
|
-
//
|
|
845
|
-
//
|
|
846
|
-
//
|
|
847
|
-
//
|
|
848
|
-
//
|
|
849
|
-
//
|
|
850
|
-
//
|
|
851
|
-
//
|
|
852
|
-
//
|
|
853
|
-
//
|
|
854
|
-
//
|
|
855
|
-
//
|
|
856
|
-
//
|
|
857
|
-
//
|
|
858
|
-
//
|
|
859
|
-
//
|
|
860
|
-
//
|
|
861
|
-
//
|
|
862
|
-
//
|
|
836
|
+
// id: "76561199265943339",
|
|
837
|
+
// rich_presence: [],
|
|
838
|
+
// persona_state: null,
|
|
839
|
+
// game_played_app_id: null,
|
|
840
|
+
// game_server_ip: null,
|
|
841
|
+
// game_server_port: null,
|
|
842
|
+
// persona_state_flags: null,
|
|
843
|
+
// online_session_instances: null,
|
|
844
|
+
// persona_set_by_user: null,
|
|
845
|
+
// player_name: "杀人不见血",
|
|
846
|
+
// query_port: null,
|
|
847
|
+
// steamid_source: null,
|
|
848
|
+
// avatar_hash: "33994e26f1fe7e2093f8c7dee66c1ac91531050d",
|
|
849
|
+
// last_logoff: null,
|
|
850
|
+
// last_logon: null,
|
|
851
|
+
// last_seen_online: null,
|
|
852
|
+
// clan_rank: null,
|
|
853
|
+
// game_name: null,
|
|
854
|
+
// gameid: null,
|
|
855
|
+
// game_data_blob: null,
|
|
856
|
+
// clan_data: null,
|
|
857
|
+
// clan_tag: null,
|
|
858
|
+
// broadcast_id: null,
|
|
859
|
+
// game_lobby_id: null,
|
|
860
|
+
// watching_broadcast_accountid: null,
|
|
861
|
+
// watching_broadcast_appid: null,
|
|
862
|
+
// watching_broadcast_viewers: null,
|
|
863
|
+
// watching_broadcast_title: null,
|
|
864
|
+
// is_community_banned: null,
|
|
865
|
+
// player_name_pending_review: null,
|
|
866
|
+
// avatar_pending_review: null,
|
|
867
|
+
// avatar_url_icon: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/33/33994e26f1fe7e2093f8c7dee66c1ac91531050d.jpg",
|
|
868
|
+
// avatar_url_medium: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/33/33994e26f1fe7e2093f8c7dee66c1ac91531050d_medium.jpg",
|
|
869
|
+
// avatar_url_full: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/33/33994e26f1fe7e2093f8c7dee66c1ac91531050d_full.jpg"
|
|
863
870
|
// }
|
|
871
|
+
|
|
872
|
+
const players = []
|
|
864
873
|
for (const player of entries) {
|
|
865
874
|
try {
|
|
866
875
|
const prime = player.apr === 1 ? 'PRIME' : 'NON-PRIME'
|
|
867
876
|
const loc = LOCS[player.loc] || player.loc
|
|
868
877
|
const steamId = SteamID.fromIndividualAccountID(player.id).getSteamID64()
|
|
869
|
-
const persona = personas.find(p => p.id == steamId)
|
|
870
878
|
const friendCode = FriendCode.encode(steamId)
|
|
871
879
|
|
|
872
880
|
// if ((LOCS[player.loc] == 'VN' || !LOCS[player.loc])) {
|
|
873
881
|
players.push({
|
|
874
882
|
prime,
|
|
875
|
-
player_name: persona.player_name,
|
|
876
883
|
rank: RANKS[player.ark] !== undefined ? RANKS[player.ark] : player.ark,
|
|
877
|
-
loc
|
|
884
|
+
loc,
|
|
878
885
|
steamId,
|
|
879
886
|
friendCode,
|
|
880
|
-
avatar_hash: persona.avatar_hash,
|
|
881
887
|
})
|
|
882
888
|
// }
|
|
883
889
|
} catch (e) {
|
|
@@ -978,66 +984,66 @@ function SteamClient({
|
|
|
978
984
|
async user(steamId, data) {
|
|
979
985
|
callEvent(events.user, {steamId: steamId.getSteamID64(), data})
|
|
980
986
|
const dataExample = {
|
|
981
|
-
|
|
987
|
+
rich_presence: [
|
|
982
988
|
{
|
|
983
|
-
|
|
984
|
-
|
|
989
|
+
key: "status",
|
|
990
|
+
value: "Competitive Mirage [ 3 : 6 ]"
|
|
985
991
|
},
|
|
986
992
|
{
|
|
987
|
-
|
|
988
|
-
|
|
993
|
+
key: "version",
|
|
994
|
+
value: "13875"
|
|
989
995
|
},
|
|
990
996
|
{
|
|
991
|
-
|
|
992
|
-
|
|
997
|
+
key: "game:state",
|
|
998
|
+
value: "game"
|
|
993
999
|
},
|
|
994
1000
|
{
|
|
995
|
-
|
|
996
|
-
|
|
1001
|
+
key: "steam_display",
|
|
1002
|
+
value: "#display_GameKnownMapScore"
|
|
997
1003
|
},
|
|
998
1004
|
{
|
|
999
|
-
|
|
1000
|
-
|
|
1005
|
+
key: "game:mode",
|
|
1006
|
+
value: "competitive"
|
|
1001
1007
|
},
|
|
1002
1008
|
{
|
|
1003
|
-
|
|
1004
|
-
|
|
1009
|
+
key: "game:mapgroupname",
|
|
1010
|
+
value: "mg_de_mirage"
|
|
1005
1011
|
},
|
|
1006
1012
|
{
|
|
1007
|
-
|
|
1008
|
-
|
|
1013
|
+
key: "game:map",
|
|
1014
|
+
value: "de_mirage"
|
|
1009
1015
|
},
|
|
1010
1016
|
{
|
|
1011
|
-
|
|
1012
|
-
|
|
1017
|
+
key: "game:server",
|
|
1018
|
+
value: "kv"
|
|
1013
1019
|
},
|
|
1014
1020
|
{
|
|
1015
|
-
|
|
1016
|
-
|
|
1021
|
+
key: "watch",
|
|
1022
|
+
value: "1"
|
|
1017
1023
|
},
|
|
1018
1024
|
{
|
|
1019
|
-
|
|
1020
|
-
|
|
1025
|
+
key: "steam_player_group",
|
|
1026
|
+
value: "2134948645"
|
|
1021
1027
|
},
|
|
1022
1028
|
{
|
|
1023
|
-
|
|
1024
|
-
|
|
1029
|
+
key: "game:score",
|
|
1030
|
+
value: "[ 3 : 6 ]"
|
|
1025
1031
|
}
|
|
1026
1032
|
],
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1033
|
+
friendid: "76561199405834425",
|
|
1034
|
+
persona_state: 1,
|
|
1035
|
+
game_played_app_id: 730,
|
|
1036
|
+
game_server_ip: null,
|
|
1037
|
+
game_server_port: null,
|
|
1038
|
+
persona_state_flags: 1,
|
|
1039
|
+
online_session_instances: 1,
|
|
1040
|
+
persona_set_by_user: null,
|
|
1041
|
+
player_name: "quỷ súng",
|
|
1042
|
+
query_port: null,
|
|
1043
|
+
steamid_source: "0",
|
|
1044
|
+
avatar_hash: {
|
|
1045
|
+
type: "Buffer",
|
|
1046
|
+
data: [
|
|
1041
1047
|
23,
|
|
1042
1048
|
163,
|
|
1043
1049
|
216,
|
|
@@ -1060,27 +1066,27 @@ function SteamClient({
|
|
|
1060
1066
|
205
|
|
1061
1067
|
]
|
|
1062
1068
|
},
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1069
|
+
last_logoff: 1683950268,
|
|
1070
|
+
last_logon: 1683950281,
|
|
1071
|
+
last_seen_online: 1683950268,
|
|
1072
|
+
clan_rank: null,
|
|
1073
|
+
game_name: "",
|
|
1074
|
+
gameid: "730",
|
|
1075
|
+
game_data_blob: {
|
|
1076
|
+
type: "Buffer",
|
|
1077
|
+
data: []
|
|
1072
1078
|
},
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1079
|
+
clan_data: null,
|
|
1080
|
+
clan_tag: null,
|
|
1081
|
+
broadcast_id: "0",
|
|
1082
|
+
game_lobby_id: "0",
|
|
1083
|
+
watching_broadcast_accountid: null,
|
|
1084
|
+
watching_broadcast_appid: null,
|
|
1085
|
+
watching_broadcast_viewers: null,
|
|
1086
|
+
watching_broadcast_title: null,
|
|
1087
|
+
is_community_banned: null,
|
|
1088
|
+
player_name_pending_review: null,
|
|
1089
|
+
avatar_pending_review: null
|
|
1084
1090
|
}
|
|
1085
1091
|
},
|
|
1086
1092
|
async playingState(playing_blocked, playing_app) {
|
|
@@ -1150,21 +1156,21 @@ function SteamClient({
|
|
|
1150
1156
|
data.message_no_bbcode = data.message_no_bbcode?.replaceAll(`ː`, `:`)
|
|
1151
1157
|
data.message = data.message?.replaceAll(`ː`, `:`)
|
|
1152
1158
|
const example = {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1159
|
+
steamid_friend: {
|
|
1160
|
+
universe: 1,
|
|
1161
|
+
type: 1,
|
|
1162
|
+
instance: 1,
|
|
1163
|
+
accountid: 1080136620
|
|
1158
1164
|
},
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1165
|
+
chat_entry_type: 1,
|
|
1166
|
+
from_limited_account: false,
|
|
1167
|
+
message: "xxx",
|
|
1168
|
+
ordinal: 0,
|
|
1169
|
+
local_echo: false,
|
|
1170
|
+
message_no_bbcode: "xxx",
|
|
1171
|
+
low_priority: false,
|
|
1172
|
+
server_timestamp: "2023-05-14T09:26:25.000Z",
|
|
1173
|
+
message_bbcode_parsed: [
|
|
1168
1174
|
"xxx"
|
|
1169
1175
|
]
|
|
1170
1176
|
}
|
|
@@ -1446,10 +1452,10 @@ function SteamClient({
|
|
|
1446
1452
|
}
|
|
1447
1453
|
|
|
1448
1454
|
async function autoRequestFreeLicense(shouldLog = false, max = 10) {
|
|
1449
|
-
const mCookies = await getCookiesWait()
|
|
1450
|
-
if (!mCookies) return
|
|
1451
|
-
const
|
|
1452
|
-
const recommendedApps = _.shuffle(
|
|
1455
|
+
// const mCookies = await getCookiesWait()
|
|
1456
|
+
// if (!mCookies) return
|
|
1457
|
+
const freeAppList = Array.isArray(steamClient.licenses) ? FreeAppList.filter(appId => steamClient.licenses.every(({package_id}) => package_id !== appId)) : FreeAppList;
|
|
1458
|
+
const recommendedApps = _.shuffle(freeAppList)
|
|
1453
1459
|
if (max) {
|
|
1454
1460
|
recommendedApps.length = Math.min(recommendedApps.length, max)
|
|
1455
1461
|
}
|
|
@@ -1477,12 +1483,12 @@ function SteamClient({
|
|
|
1477
1483
|
// }
|
|
1478
1484
|
// }
|
|
1479
1485
|
|
|
1480
|
-
if (shouldLog) {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}
|
|
1486
|
+
// if (shouldLog) {
|
|
1487
|
+
// await sleep(20000)
|
|
1488
|
+
// const ownedAppsCount2 = (await steamUtils.getDynamicStoreUserData())?.rgOwnedApps?.length || 0
|
|
1489
|
+
// const increaseNumber = ownedAppsCount2 - ownedAppsCount;
|
|
1490
|
+
// log(`OwnedApps length ${ownedAppsCount2}, increase ${increaseNumber}`)
|
|
1491
|
+
// }
|
|
1486
1492
|
}
|
|
1487
1493
|
|
|
1488
1494
|
async function playCSGO() {
|
|
@@ -1581,7 +1587,10 @@ function SteamClient({
|
|
|
1581
1587
|
if (!Array.isArray(apps)) {
|
|
1582
1588
|
apps = [apps]
|
|
1583
1589
|
}
|
|
1584
|
-
|
|
1590
|
+
|
|
1591
|
+
appsPlayed.length = 0
|
|
1592
|
+
appsPlayed.push(...apps)
|
|
1593
|
+
|
|
1585
1594
|
if (apps.length) {
|
|
1586
1595
|
state = 'InGame'
|
|
1587
1596
|
} else {
|
|
@@ -1610,28 +1619,28 @@ function SteamClient({
|
|
|
1610
1619
|
/*
|
|
1611
1620
|
users
|
|
1612
1621
|
* {
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
+
rich_presence: [],
|
|
1623
|
+
player_name: "Kei #SkinsMonkey",
|
|
1624
|
+
avatar_hash: [123,4543],
|
|
1625
|
+
last_logoff: "2023-05-20T05:00:42.000Z",
|
|
1626
|
+
last_logon: "2023-05-20T05:02:16.000Z",
|
|
1627
|
+
last_seen_online: "2023-05-20T05:00:42.000Z",
|
|
1628
|
+
avatar_url_icon: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/3e/3e9da0b107ac2ec384759544368a8a977359537a.jpg",
|
|
1629
|
+
avatar_url_medium: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/3e/3e9da0b107ac2ec384759544368a8a977359537a_medium.jpg",
|
|
1630
|
+
avatar_url_full: "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/3e/3e9da0b107ac2ec384759544368a8a977359537a_full.jpg"
|
|
1622
1631
|
}
|
|
1623
1632
|
*
|
|
1624
1633
|
|
|
1625
1634
|
myFriends
|
|
1626
1635
|
{
|
|
1627
|
-
|
|
1628
|
-
|
|
1636
|
+
76561198365087582: 3,
|
|
1637
|
+
76561199490395123: 3
|
|
1629
1638
|
}
|
|
1630
1639
|
* */
|
|
1631
1640
|
/*steamClient._send({
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1641
|
+
msg: 151,
|
|
1642
|
+
proto: {
|
|
1643
|
+
target_job_name: methodName
|
|
1635
1644
|
}
|
|
1636
1645
|
}, Buffer.alloc(0), function (body, hdr) {
|
|
1637
1646
|
const result = hdr.proto.eresult
|
|
@@ -1764,6 +1773,29 @@ function SteamClient({
|
|
|
1764
1773
|
},
|
|
1765
1774
|
getLastTimePartySearch(){
|
|
1766
1775
|
return lastTimePartySearch
|
|
1776
|
+
},
|
|
1777
|
+
getLicenses(){
|
|
1778
|
+
return steamClient.licenses
|
|
1779
|
+
const exampleLicenses = [{
|
|
1780
|
+
package_id: 303386,
|
|
1781
|
+
time_created: 1680491335,
|
|
1782
|
+
time_next_process: 0,
|
|
1783
|
+
minute_limit: 0,
|
|
1784
|
+
minutes_used: 0,
|
|
1785
|
+
payment_method: 1024,
|
|
1786
|
+
flags: 512,
|
|
1787
|
+
purchase_country_code: "VN",
|
|
1788
|
+
license_type: 1,
|
|
1789
|
+
territory_code: 0,
|
|
1790
|
+
change_number: 20615891,
|
|
1791
|
+
owner_id: 1530068060,
|
|
1792
|
+
initial_period: 0,
|
|
1793
|
+
initial_time_unit: 0,
|
|
1794
|
+
renewal_period: 0,
|
|
1795
|
+
renewal_time_unit: 0,
|
|
1796
|
+
access_token: "8049398090486337961",
|
|
1797
|
+
master_package_id: null
|
|
1798
|
+
}]
|
|
1767
1799
|
}
|
|
1768
1800
|
}
|
|
1769
1801
|
}
|
package/index.js
CHANGED
|
@@ -1319,8 +1319,8 @@ class SteamUser {
|
|
|
1319
1319
|
}
|
|
1320
1320
|
}
|
|
1321
1321
|
|
|
1322
|
-
static async
|
|
1323
|
-
for (let i = 0; i <
|
|
1322
|
+
static async getAppVersion(appID) {
|
|
1323
|
+
for (let i = 0; i < 3; i++) {
|
|
1324
1324
|
try {
|
|
1325
1325
|
return (await request(
|
|
1326
1326
|
`https://api.steampowered.com/ISteamApps/UpToDateCheck/v1/?format=json&appid=${appID}&version=0`)).data.response.required_version
|
|
@@ -5490,8 +5490,7 @@ class SteamUser {
|
|
|
5490
5490
|
const $ = cheerio.load(html)
|
|
5491
5491
|
|
|
5492
5492
|
const tradehistory = []
|
|
5493
|
-
|
|
5494
|
-
const tradehistoryrow_el = $(this)
|
|
5493
|
+
for (const tradehistoryrow_el of querySelectorAll($, '.tradehistoryrow')) {
|
|
5495
5494
|
const tradehistory_date_el = tradehistoryrow_el.find('.tradehistory_date')
|
|
5496
5495
|
const tradehistory_timestamp_el = tradehistory_date_el.find('.tradehistory_timestamp')
|
|
5497
5496
|
|
|
@@ -5584,11 +5583,10 @@ class SteamUser {
|
|
|
5584
5583
|
|
|
5585
5584
|
const plusminus = tradehistoryrow_el.find('.tradehistory_items_plusminus').text().trim()//+ -
|
|
5586
5585
|
const tradehistory_items = []
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
const
|
|
5590
|
-
|
|
5591
|
-
const itemEl = $(this)
|
|
5586
|
+
|
|
5587
|
+
for (const tradehistory_items_el of querySelectorAll($, '.tradehistory_items', tradehistoryrow_el)) {
|
|
5588
|
+
const plusminus = tradehistory_items_el.find('.tradehistory_items_plusminus').text().trim()
|
|
5589
|
+
for (const itemEl of querySelectorAll($, '.tradehistory_items_group > .history_item', tradehistory_items_el)) {
|
|
5592
5590
|
const text = plainText(itemEl.text())//You did not receive any items in this trade.
|
|
5593
5591
|
const appID = itemEl.attr('data-appid')
|
|
5594
5592
|
const classid = itemEl.attr('data-classid')
|
|
@@ -5602,14 +5600,14 @@ class SteamUser {
|
|
|
5602
5600
|
instanceid,
|
|
5603
5601
|
contextid,
|
|
5604
5602
|
steamId,
|
|
5605
|
-
plusminus
|
|
5603
|
+
plusminus,
|
|
5606
5604
|
...(descriptions[appID]?.[classid + '_' + instanceid])
|
|
5607
5605
|
})
|
|
5608
5606
|
}
|
|
5609
|
-
}
|
|
5610
|
-
}
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5611
5609
|
|
|
5612
|
-
if(tradehistory_items.length){
|
|
5610
|
+
if (tradehistory_items.length) {
|
|
5613
5611
|
const id = [timestamp, description, plusminus, tradehistory_items.map(item => (item.classid || '0') + "_" + (item.instanceid || '0')).join('|')]
|
|
5614
5612
|
.map(item => item.toString().replaceAll(/[^a-zA-Z0-9-+_|]/gi, ''))
|
|
5615
5613
|
.join('_').toLowerCase()
|
|
@@ -5628,7 +5626,7 @@ class SteamUser {
|
|
|
5628
5626
|
fs.writeFileSync('tradehistory_items_empty_' + steamId + "_" + new Date().getTime(), html)
|
|
5629
5627
|
console.error("tradehistory_items empty", steamId);
|
|
5630
5628
|
}
|
|
5631
|
-
}
|
|
5629
|
+
}
|
|
5632
5630
|
|
|
5633
5631
|
return {cursor: result.cursor, tradehistory}
|
|
5634
5632
|
const exampleTradeHistory = [
|
|
@@ -6100,4 +6098,17 @@ function plainText(text) {
|
|
|
6100
6098
|
return text?.replaceAll(/[\t\n\r]/gi, ' ')?.replaceAll(/\s+/g, ' ')?.trim()
|
|
6101
6099
|
}
|
|
6102
6100
|
|
|
6101
|
+
function querySelectorAll($, selector, root) {
|
|
6102
|
+
try {
|
|
6103
|
+
if (root) {
|
|
6104
|
+
return [...root.find(selector)].map(el => $(el))
|
|
6105
|
+
} else {
|
|
6106
|
+
return [...$(selector)].map(el => $(el))
|
|
6107
|
+
}
|
|
6108
|
+
} catch (e) {
|
|
6109
|
+
console.error(e);
|
|
6110
|
+
return []
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
|
|
6103
6114
|
export default SteamUser
|