steamutils 1.4.34 → 1.4.36

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 CHANGED
@@ -1,28 +1,15 @@
1
1
  import NodeSteamUser from "steam-user";
2
2
  import _ from "lodash";
3
- import fs from "fs";
4
- import { protoDecode, protoEncode } from "./helpers/util.js";
5
3
  import SteamID from "steamid";
6
4
  import FriendCode from "csgo-friendcode";
7
5
  import axios from "axios";
8
- import helpers, { loadProfos } from "./helpers/protos.js";
9
- import { fileURLToPath } from "url";
10
- import path from "path";
11
6
  import SteamUser from "./index.js";
12
7
  import { v4 as uuidv4 } from "uuid";
13
8
  import EFriendRelationship from "steam-user/enums/EFriendRelationship.js";
14
9
  import SteamCommunity from "steamcommunity";
15
10
  import moment from "moment-timezone";
16
11
  import { encode, encodeUids } from "./bufferHelpers.js";
17
-
18
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
-
20
- const Protos = helpers([
21
- {
22
- name: "csgo",
23
- protos: loadProfos(`${__dirname}/protos/`),
24
- },
25
- ]);
12
+ import { ESteamProto, SteamProto, SteamProtoType } from "./steamproto.js";
26
13
 
27
14
  export const RANKS = {
28
15
  0: "Unranked",
@@ -76,12 +63,34 @@ export const LOCS = {
76
63
 
77
64
  const AppID = 730;
78
65
  export let CSGO_VER = 13960;
79
- export const FreeAppList = JSON.parse(fs.readFileSync(path.join(__dirname, "free_packages.json"))).packages;
80
66
 
81
67
  SteamUser.getAppVersion(AppID).then(function (ver) {
82
68
  CSGO_VER = ver;
83
69
  });
84
70
 
71
+ export const SteamClientEvents = {
72
+ user: "user",
73
+ loggedOn: "loggedOn",
74
+ csgoOnline: "csgoOnline",
75
+ csgoClientHello: "csgoClientHello",
76
+ webSession: "webSession",
77
+ friendMessage: "friendMessage",
78
+ friendTyping: "friendTyping",
79
+ disconnected: "disconnected",
80
+ error: "error",
81
+ playersProfile: "playersProfile",
82
+ fatalError: "fatalError",
83
+ partyInvite: "partyInvite",
84
+ friendRelationship: "friendRelationship",
85
+ tradeOffers: "tradeOffers",
86
+ offlineMessages: "offlineMessages",
87
+ friendsList: "friendsList",
88
+ gifts: "gifts",
89
+ playingState: "playingState",
90
+ emailInfo: "emailInfo",
91
+ accountLimitations: "accountLimitations",
92
+ wallet: "wallet",
93
+ };
85
94
  const PersonasCache = [];
86
95
  let isSendingFriendMessages = false;
87
96
 
@@ -92,7 +101,6 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
92
101
  let isLogOff = false;
93
102
  let playingBlocked = null;
94
103
  const richPresence = {};
95
- let sendMessageTimestamp = 0;
96
104
  let lastTimePartyRegister = 0;
97
105
  let lastTimePartySearch = 0;
98
106
  const ownedApps = [];
@@ -108,29 +116,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
108
116
 
109
117
  const onAnyCallbacks = [];
110
118
 
111
- const events = {
112
- user: [],
113
- loggedOn: [],
114
- csgoOnline: [],
115
- csgoClientHello: [],
116
- webSession: [],
117
- friendMessage: [],
118
- friendTyping: [],
119
- disconnected: [],
120
- error: [],
121
- playersProfile: [],
122
- fatalError: [],
123
- partyInvite: [],
124
- friendRelationship: [],
125
- tradeOffers: [],
126
- offlineMessages: [],
127
- friendsList: [],
128
- gifts: [],
129
- playingState: [],
130
- emailInfo: [],
131
- accountLimitations: [],
132
- wallet: [],
133
- };
119
+ const events = { ...SteamClientEvents };
120
+ for (const name in SteamClientEvents) {
121
+ events[name] = [];
122
+ }
134
123
 
135
124
  const gcCallback = {};
136
125
 
@@ -395,9 +384,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
395
384
  const players = await new Promise((resolve) => {
396
385
  steamClient.sendToGC(
397
386
  AppID,
398
- Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search,
387
+ ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search,
399
388
  {},
400
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_Party_Search, {
389
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Search).protoEncode({
401
390
  ver: CSGO_VER,
402
391
  apr: prime ? 1 : 0,
403
392
  ark: parseInt(Object.keys(RANKS).find((k) => RANKS[k] === rank)) * 10,
@@ -406,7 +395,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
406
395
  game_type: game_type === "Competitive" ? 8 : 10,
407
396
  }),
408
397
  );
409
- lastTimePartySearch = new Date().getTime();
398
+ lastTimePartySearch = Date.now();
410
399
  pushGCCallback("partySearch", resolve, timeout);
411
400
  });
412
401
  if (Array.isArray(players) && players.length) {
@@ -434,13 +423,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
434
423
 
435
424
  steamClient._send(
436
425
  {
437
- msg: Protos.csgo.EMsg.k_EMsgClientMMSCreateLobby,
426
+ msg: ESteamProto.EMsg.k_EMsgClientMMSCreateLobby,
438
427
  proto: {
439
428
  steamid: steamClient.steamID.getSteamID64(),
440
429
  routing_appid: 730,
441
430
  },
442
431
  },
443
- protoEncode(Protos.csgo.CMsgClientMMSCreateLobby, {
432
+ new SteamProto(SteamProtoType.CMsgClientMMSCreateLobby).protoEncode({
444
433
  app_id: 730,
445
434
  max_members: 1,
446
435
  lobby_type: 1,
@@ -448,24 +437,24 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
448
437
  }),
449
438
  function (payload) {
450
439
  clearTimeout(timeout);
451
- const result = protoDecode(Protos.csgo.CMsgClientMMSCreateLobbyResponse, payload.toBuffer());
440
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSCreateLobbyResponse).protoEncode(payload.toBuffer());
452
441
  const steam_id_lobby = result.steam_id_lobby.toString();
453
442
  currentLobby.lobbyID = steam_id_lobby;
454
- currentLobby.timestamp = new Date().getTime();
443
+ currentLobby.timestamp = Date.now();
455
444
  resolve(steam_id_lobby);
456
445
  },
457
446
  );
458
447
  });
459
448
 
460
- // return await getHandlerResult(Protos.csgo.EMsg.k_EMsgClientMMSCreateLobbyResponse, function (payload) {
461
- // const result = protoDecode(Protos.csgo.CMsgClientMMSCreateLobbyResponse, payload.toBuffer())
449
+ // return await getHandlerResult(ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse, function (payload) {
450
+ // const result = protoDecode(SteamProtoType.CMsgClientMMSCreateLobbyResponse, payload.toBuffer())
462
451
  // return result.steam_id_lobby.toString()
463
452
  // })
464
453
 
465
- // steamClient.sendToGC(730, Protos.csgo.EMsg.k_EMsgClientMMSCreateLobby, {
454
+ // steamClient.sendToGC(730, ESteamProto.EMsg.k_EMsgClientMMSCreateLobby, {
466
455
  // steamid: steamClient.steamID,
467
456
  // routing_appid: 730,
468
- // }, protoEncode(Protos.csgo.CMsgClientMMSCreateLobby, {
457
+ // }, protoEncode(SteamProtoType.CMsgClientMMSCreateLobby, {
469
458
  // app_id: 730,
470
459
  // max_members: 1,
471
460
  // lobby_type: 1,
@@ -485,13 +474,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
485
474
 
486
475
  steamClient._send(
487
476
  {
488
- msg: Protos.csgo.EMsg.k_EMsgClientMMSSetLobbyData,
477
+ msg: ESteamProto.EMsg.k_EMsgClientMMSSetLobbyData,
489
478
  proto: {
490
479
  steamid: steamClient.steamID.getSteamID64(),
491
480
  routing_appid: 730,
492
481
  },
493
482
  },
494
- protoEncode(Protos.csgo.CMsgClientMMSSetLobbyData, {
483
+ new SteamProto(SteamProtoType.CMsgClientMMSSetLobbyData).protoEncode({
495
484
  app_id: 730,
496
485
  steam_id_lobby: lobbyID,
497
486
  steam_id_member: "0",
@@ -521,17 +510,17 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
521
510
  }),
522
511
  function (payload) {
523
512
  clearTimeout(timeout);
524
- const result = protoDecode(Protos.csgo.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer());
513
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSSetLobbyDataResponse).protoDecode(payload.toBuffer());
525
514
  const steam_id_lobby = result.steam_id_lobby.toString();
526
515
  currentLobby.lobbyID = steam_id_lobby;
527
- currentLobby.timestamp = new Date().getTime();
516
+ currentLobby.timestamp = Date.now();
528
517
  resolve(steam_id_lobby);
529
518
  },
530
519
  );
531
520
  });
532
521
 
533
- // return await getHandlerResult(Protos.csgo.EMsg.k_EMsgClientMMSSetLobbyDataResponse, function (payload) {
534
- // const result = protoDecode(Protos.csgo.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer())
522
+ // return await getHandlerResult(ESteamProto.EMsg.k_EMsgClientMMSSetLobbyDataResponse, function (payload) {
523
+ // const result = protoDecode(SteamProtoType.CMsgClientMMSSetLobbyDataResponse, payload.toBuffer())
535
524
  // return result.steam_id_lobby.toString()
536
525
  // })
537
526
  }
@@ -543,13 +532,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
543
532
 
544
533
  steamClient._send(
545
534
  {
546
- msg: Protos.csgo.EMsg.k_EMsgClientMMSInviteToLobby,
535
+ msg: ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby,
547
536
  proto: {
548
537
  steamid: steamClient.steamID.getSteamID64(),
549
538
  routing_appid: 730,
550
539
  },
551
540
  },
552
- protoEncode(Protos.csgo.CMsgClientMMSInviteToLobby, {
541
+ new SteamProto(SteamProtoType.CMsgClientMMSInviteToLobby).protoEncode({
553
542
  app_id: 730,
554
543
  steam_id_lobby: lobbyID,
555
544
  steam_id_user_invited: steamId,
@@ -558,9 +547,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
558
547
 
559
548
  // lobbyID = new SteamID(lobbyID).accountid;
560
549
 
561
- // Protos.csgo.EMsg.k_EMsgGCHInviteUserToLobby
562
- // Protos.csgo.EMsg.k_EMsgClientMMSInviteToLobby
563
- // steamClient.sendToGC(730, Protos.csgo.EMsg.k_EMsgClientMMSInviteToLobby, {}, protoEncode(Protos.csgo.CMsgClientMMSInviteToLobby, {
550
+ // ESteamProto.EMsg.k_EMsgGCHInviteUserToLobby
551
+ // ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby
552
+ // steamClient.sendToGC(730, ESteamProto.EMsg.k_EMsgClientMMSInviteToLobby, {}, protoEncode(SteamProtoType.CMsgClientMMSInviteToLobby, {
564
553
  // app_id: 730,
565
554
  // steam_id_lobby: lobbyID,
566
555
  // steam_id_user_invited: accountid,
@@ -579,7 +568,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
579
568
  }
580
569
 
581
570
  let lobbyID = null;
582
- if (currentLobby.lobbyID && currentLobby.timestamp > new Date().getTime() - 30000) {
571
+ if (currentLobby.lobbyID && currentLobby.timestamp > Date.now() - 30000) {
583
572
  //30 seconds
584
573
  lobbyID = currentLobby.lobbyID;
585
574
  } else {
@@ -607,19 +596,19 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
607
596
 
608
597
  steamClient._send(
609
598
  {
610
- msg: Protos.csgo.EMsg.k_EMsgClientMMSGetLobbyData,
599
+ msg: ESteamProto.EMsg.k_EMsgClientMMSGetLobbyData,
611
600
  proto: {
612
601
  steamid: steamClient.steamID.getSteamID64(),
613
602
  routing_appid: 730,
614
603
  },
615
604
  },
616
- protoEncode(Protos.csgo.CMsgClientMMSGetLobbyData, {
605
+ new SteamProto(SteamProtoType.CMsgClientMMSGetLobbyData).protoEncode({
617
606
  app_id: 730,
618
607
  steam_id_lobby: lobbyID.toString(),
619
608
  }),
620
609
  function (payload) {
621
610
  clearTimeout(timeout);
622
- const result = protoDecode(Protos.csgo.CMsgClientMMSLobbyData, payload.toBuffer());
611
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSLobbyData).protoDecode(payload.toBuffer());
623
612
  result.steam_id_lobby = result.steam_id_lobby.toString();
624
613
  resolve(result);
625
614
  },
@@ -632,19 +621,19 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
632
621
 
633
622
  steamClient._send(
634
623
  {
635
- msg: Protos.csgo.EMsg.k_EMsgClientMMSJoinLobby,
624
+ msg: ESteamProto.EMsg.k_EMsgClientMMSJoinLobby,
636
625
  proto: {
637
626
  steamid: steamClient.steamID.getSteamID64(),
638
627
  routing_appid: 730,
639
628
  },
640
629
  }, //CMsgClientMMSUserJoinedLobby CMsgClientMMSJoinLobby
641
- protoEncode(Protos.csgo.CMsgClientMMSJoinLobby, {
630
+ new SteamProto(SteamProtoType.CMsgClientMMSJoinLobby).protoEncode({
642
631
  app_id: 730,
643
632
  steam_id_lobby: lobbyID,
644
633
  persona_name: steamClient.accountInfo.name,
645
634
  }),
646
635
  function (payload) {
647
- const result = protoDecode(Protos.csgo.CMsgClientMMSJoinLobbyResponse, payload.toBuffer());
636
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSJoinLobbyResponse).protoDecode(payload.toBuffer());
648
637
  result.steam_id_lobby = result.steam_id_lobby.toString();
649
638
  result.steam_id_owner = result.steam_id_owner.toString();
650
639
  console.log(result);
@@ -664,14 +653,14 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
664
653
  }
665
654
 
666
655
  async function sendHello() {
667
- steamClient.sendToGC(AppID, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello, {}, Buffer.alloc(0));
668
- // steamClient.sendToGC(AppID, Protos.csgo.EGCBaseClientMsg.k_EMsgGCClientHello, {}, Buffer.alloc(0));
656
+ steamClient.sendToGC(AppID, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello, {}, Buffer.alloc(0));
657
+ // steamClient.sendToGC(AppID, ESteamProto.EGCBaseClientMsg.k_EMsgGCClientHello, {}, Buffer.alloc(0));
669
658
 
670
659
  steamClient.sendToGC(
671
660
  AppID,
672
- Protos.csgo.EGCBaseClientMsg.k_EMsgGCClientHello,
661
+ ESteamProto.EGCBaseClientMsg.k_EMsgGCClientHello,
673
662
  {},
674
- protoEncode(Protos.csgo.CMsgClientHello, {
663
+ new SteamProto(SteamProtoType.CMsgClientHello).protoEncode({
675
664
  version: 2000258, //get from https://github.com/SteamDatabase/GameTracking-CS2/commits
676
665
  client_session_need: 0,
677
666
  client_launcher: 0,
@@ -682,7 +671,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
682
671
 
683
672
  async function requestCoPlays() {
684
673
  return new Promise((resolve) => {
685
- steamClient.sendToGC(AppID, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays, {}, Buffer.alloc(0));
674
+ steamClient.sendToGC(AppID, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays, {}, Buffer.alloc(0));
686
675
  pushGCCallback("RequestCoPlays", resolve, 30000);
687
676
  });
688
677
  }
@@ -707,7 +696,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
707
696
  const isSuccess = await login(true);
708
697
  if (isSuccess) {
709
698
  const loggedOnResponse = await new Promise((resolve) => {
710
- onEvent("loggedOn", resolve, true, 180000);
699
+ onEvent(SteamClientEvents.loggedOn, resolve, true, 180000);
711
700
  });
712
701
  if (loggedOnResponse) {
713
702
  console.log("Relogin success");
@@ -789,17 +778,17 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
789
778
  async receivedFromGC(appid, msgType, payload) {
790
779
  const key = getECsgoGCMsgKey(msgType);
791
780
  switch (msgType) {
792
- case Protos.csgo.EMsg.k_EMsgClientChatInvite: {
781
+ case ESteamProto.EMsg.k_EMsgClientChatInvite: {
793
782
  log(payload);
794
783
  break;
795
784
  }
796
- case Protos.csgo.ECsgoGCMsg.k_EMsgClientMMSJoinLobbyResponse: {
797
- const msg = protoDecode(Protos.csgo.CMsgClientMMSJoinLobbyResponse, payload);
785
+ case ESteamProto.ECsgoGCMsg.k_EMsgClientMMSJoinLobbyResponse: {
786
+ const msg = new SteamProto(SteamProtoType.CMsgClientMMSJoinLobbyResponse).protoDecode(payload);
798
787
  log(msg);
799
788
  break;
800
789
  }
801
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
802
- const msg = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_Invite, payload);
790
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Invite: {
791
+ const msg = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Invite).protoDecode(payload);
803
792
  const sid64 = SteamID.fromIndividualAccountID(msg.accountid).getSteamID64();
804
793
  if (events.partyInvite?.length) {
805
794
  const personas = await getPersonas([sid64]);
@@ -813,22 +802,22 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
813
802
  // joinLobby(msg.lobbyid, msg.accountid)
814
803
  break;
815
804
  }
816
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays: {
817
- const msg = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Account_RequestCoPlays, payload);
805
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Account_RequestCoPlays: {
806
+ const msg = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Account_RequestCoPlays).protoDecode(payload);
818
807
  const personas = msg.players.map((p) => SteamID.fromIndividualAccountID(p.accountid));
819
808
  callGCCallback("RequestCoPlays", personas);
820
809
  break;
821
810
  }
822
- case Protos.csgo.EGCBaseClientMsg.k_EMsgGCClientWelcome: {
811
+ case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientWelcome: {
823
812
  prime = false;
824
- const CMsgClientWelcome = protoDecode(Protos.csgo.CMsgClientWelcome, payload);
813
+ const CMsgClientWelcome = new SteamProto(SteamProtoType.CMsgClientWelcome).protoDecode(payload);
825
814
  const obj = {};
826
815
  for (const outofdate_cache of CMsgClientWelcome.outofdate_subscribed_caches) {
827
816
  for (const cache_object of outofdate_cache.objects) {
828
817
  for (const object_data of cache_object.object_data) {
829
818
  switch (cache_object.type_id) {
830
819
  case 1: {
831
- const result = protoDecode(Protos.csgo.CSOEconItem, object_data);
820
+ const result = new SteamProto(SteamProtoType.CSOEconItem).protoDecode(object_data);
832
821
  result.id = result.id.toNumber();
833
822
  result.original_id = result.original_id.toNumber();
834
823
  if (!obj.items) {
@@ -838,7 +827,7 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
838
827
  break;
839
828
  }
840
829
  case 2: {
841
- const result = protoDecode(Protos.csgo.CSOPersonaDataPublic, object_data);
830
+ const result = new SteamProto(SteamProtoType.CSOPersonaDataPublic).protoDecode(object_data);
842
831
  obj.PersonaDataPublic = result;
843
832
  const example = {
844
833
  player_level: 4, //CSGO_Profile_Rank
@@ -852,11 +841,11 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
852
841
  break;
853
842
  }
854
843
  case 5: {
855
- const result = protoDecode(Protos.csgo.CSOItemRecipe, object_data);
844
+ const result = new SteamProto(SteamProtoType.CSOItemRecipe).protoDecode(object_data);
856
845
  break;
857
846
  }
858
847
  case 7: {
859
- const CSOEconGameAccountClient = protoDecode(Protos.csgo.CSOEconGameAccountClient, object_data);
848
+ const CSOEconGameAccountClient = new SteamProto(SteamProtoType.CSOEconGameAccountClient).protoDecode(object_data);
860
849
  const CSOEconGameAccountClientExample = {
861
850
  additional_backpack_slots: 0,
862
851
  bonus_xp_timestamp_refresh: 1688518800, //Wednesday 1:00:00 AM every week
@@ -881,36 +870,36 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
881
870
  }
882
871
 
883
872
  case 35: {
884
- // const result =protoDecode(Protos.csgo.CSOSelectedItemPreset, object_data);
873
+ // const result =protoDecode(SteamProtoType.CSOSelectedItemPreset, object_data);
885
874
  break;
886
875
  }
887
876
 
888
877
  case 36: {
889
- // const result =protoDecode(Protos.csgo.CSOEconItemPresetInstance, object_data);
878
+ // const result =protoDecode(SteamProtoType.CSOEconItemPresetInstance, object_data);
890
879
  break;
891
880
  }
892
881
  case 38: {
893
- const result = protoDecode(Protos.csgo.CSOEconItemDropRateBonus, object_data);
882
+ const result = new SteamProto(SteamProtoType.CSOEconItemDropRateBonus).protoDecode(object_data);
894
883
  break;
895
884
  }
896
885
  case 39: {
897
- const result = protoDecode(Protos.csgo.CSOEconItemLeagueViewPass, object_data);
886
+ const result = new SteamProto(SteamProtoType.CSOEconItemLeagueViewPass).protoDecode(object_data);
898
887
  break;
899
888
  }
900
889
  case 40: {
901
- const result = protoDecode(Protos.csgo.CSOEconItemEventTicket, object_data);
890
+ const result = new SteamProto(SteamProtoType.CSOEconItemEventTicket).protoDecode(object_data);
902
891
  break;
903
892
  }
904
893
  case 41: {
905
- const result = protoDecode(Protos.csgo.CSOAccountSeasonalOperation, object_data);
894
+ const result = new SteamProto(SteamProtoType.CSOAccountSeasonalOperation).protoDecode(object_data);
906
895
  break;
907
896
  }
908
897
  case 42: {
909
- // const result =protoDecode(Protos.csgo.CSOEconItemTournamentPassport, object_data);
898
+ // const result =protoDecode(SteamProtoType.CSOEconItemTournamentPassport, object_data);
910
899
  break;
911
900
  }
912
901
  case 43: {
913
- const result = protoDecode(Protos.csgo.CSOEconDefaultEquippedDefinitionInstanceClient, object_data);
902
+ const result = new SteamProto(SteamProtoType.CSOEconDefaultEquippedDefinitionInstanceClient).protoDecode(object_data);
914
903
  const example = {
915
904
  account_id: 1080136620,
916
905
  item_definition: 61,
@@ -920,15 +909,15 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
920
909
  break;
921
910
  }
922
911
  case 45: {
923
- const result = protoDecode(Protos.csgo.CSOEconCoupon, object_data);
912
+ const result = new SteamProto(SteamProtoType.CSOEconCoupon).protoDecode(object_data);
924
913
  break;
925
914
  }
926
915
  case 46: {
927
- const result = protoDecode(Protos.csgo.CSOQuestProgress, object_data);
916
+ const result = new SteamProto(SteamProtoType.CSOQuestProgress).protoDecode(object_data);
928
917
  break;
929
918
  }
930
919
  case 4: {
931
- const result = protoDecode(Protos.csgo.CSOAccountItemPersonalStore, object_data);
920
+ const result = new SteamProto(SteamProtoType.CSOAccountItemPersonalStore).protoDecode(object_data);
932
921
  result.generation_time = result.generation_time * 1000;
933
922
  if (Array.isArray(result.items)) {
934
923
  result.items = result.items.map((item) => item.toNumber());
@@ -964,24 +953,24 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
964
953
  }
965
954
  break;
966
955
  }
967
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate: {
968
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate, payload);
956
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate: {
957
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientUpdate).protoDecode(payload);
969
958
  break;
970
959
  }
971
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientGlobalStats: {
972
- const result = protoDecode(Protos.csgo.CMsgClientUGSGetGlobalStatsResponse, payload);
960
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientGlobalStats: {
961
+ const result = new SteamProto(SteamProtoType.CMsgClientUGSGetGlobalStatsResponse).protoDecode(payload);
973
962
  break;
974
963
  }
975
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer: {
976
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientReportPlayer, payload);
964
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportPlayer: {
965
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportPlayer).protoDecode(payload);
977
966
  break;
978
967
  }
979
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientTextMsg: {
980
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_GC2ClientTextMsg, payload);
968
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GC2ClientTextMsg: {
969
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GC2ClientTextMsg).protoDecode(payload);
981
970
  break;
982
971
  }
983
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello: {
984
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_MatchmakingGC2ClientHello, payload);
972
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingGC2ClientHello: {
973
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchmakingGC2ClientHello).protoDecode(payload);
985
974
  const example = {
986
975
  my_current_event_teams: [],
987
976
  my_current_event_stages: [],
@@ -1048,64 +1037,64 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1048
1037
  callEvent(events.csgoClientHello, result);
1049
1038
  break;
1050
1039
  }
1051
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportResponse: {
1052
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientReportResponse, payload);
1040
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientReportResponse: {
1041
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientReportResponse).protoDecode(payload);
1053
1042
  break;
1054
1043
  }
1055
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse: {
1056
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientCommendPlayer, payload);
1044
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientCommendPlayerQueryResponse: {
1045
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientCommendPlayer).protoDecode(payload);
1057
1046
  break;
1058
1047
  }
1059
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment: {
1060
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment, payload);
1048
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment: {
1049
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayerOverwatchCaseAssignment).protoDecode(payload);
1061
1050
  break;
1062
1051
  }
1063
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchList: {
1064
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_MatchList, payload);
1052
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchList: {
1053
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_MatchList).protoDecode(payload);
1065
1054
  break;
1066
1055
  }
1067
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GetEventFavorites_Response: {
1068
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_GetEventFavorites_Response, payload);
1056
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_GetEventFavorites_Response: {
1057
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_GetEventFavorites_Response).protoDecode(payload);
1069
1058
  break;
1070
1059
  }
1071
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_StartAgreementSessionInGame: {
1060
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_StartAgreementSessionInGame: {
1072
1061
  break;
1073
1062
  }
1074
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_ClientDeepStats: {
1075
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_ClientDeepStats, payload);
1063
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_ClientDeepStats: {
1064
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_ClientDeepStats).protoDecode(payload);
1076
1065
  break;
1077
1066
  }
1078
- case Protos.csgo.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus: {
1079
- const result = protoDecode(Protos.csgo.CMsgConnectionStatus, payload);
1067
+ case ESteamProto.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus: {
1068
+ const result = new SteamProto(SteamProtoType.CMsgConnectionStatus).protoDecode(payload);
1080
1069
  break;
1081
1070
  }
1082
- case Protos.csgo.EGCItemMsg.k_EMsgGCStoreGetUserDataResponse: {
1083
- const result = protoDecode(Protos.csgo.CMsgStoreGetUserDataResponse, payload);
1071
+ case ESteamProto.EGCItemMsg.k_EMsgGCStoreGetUserDataResponse: {
1072
+ const result = new SteamProto(SteamProtoType.CMsgStoreGetUserDataResponse).protoDecode(payload);
1084
1073
  break;
1085
1074
  }
1086
- case Protos.csgo.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse: {
1087
- const result = protoDecode(Protos.csgo.CMsgGCStorePurchaseFinalizeResponse, payload);
1075
+ case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseFinalizeResponse: {
1076
+ const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseFinalizeResponse).protoDecode(payload);
1088
1077
  break;
1089
1078
  }
1090
- case Protos.csgo.EGCItemMsg.k_EMsgGCStorePurchaseCancelResponse: {
1091
- const result = protoDecode(Protos.csgo.CMsgGCStorePurchaseCancelResponse, payload);
1079
+ case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseCancelResponse: {
1080
+ const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseCancelResponse).protoDecode(payload);
1092
1081
  break;
1093
1082
  }
1094
- case Protos.csgo.EGCItemMsg.k_EMsgGCStorePurchaseInitResponse: {
1095
- const result = protoDecode(Protos.csgo.CMsgGCStorePurchaseInitResponse, payload);
1083
+ case ESteamProto.EGCItemMsg.k_EMsgGCStorePurchaseInitResponse: {
1084
+ const result = new SteamProto(SteamProtoType.CMsgGCStorePurchaseInitResponse).protoDecode(payload);
1096
1085
  break;
1097
1086
  }
1098
- case Protos.csgo.EMsg.k_EMsgClientMMSCreateLobbyResponse: {
1099
- const result = protoDecode(Protos.csgo.CMsgClientMMSCreateLobbyResponse, payload);
1087
+ case ESteamProto.EMsg.k_EMsgClientMMSCreateLobbyResponse: {
1088
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSCreateLobbyResponse).protoDecode(payload);
1100
1089
  console.log("k_EMsgClientMMSCreateLobbyResponse", result);
1101
1090
  break;
1102
1091
  }
1103
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate: {
1104
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientGCRankUpdate, payload);
1092
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate: {
1093
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientGCRankUpdate).protoDecode(payload);
1105
1094
  break;
1106
1095
  }
1107
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search: {
1108
- const result = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_Party_SearchResults, payload);
1096
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Search: {
1097
+ const result = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_SearchResults).protoDecode(payload);
1109
1098
  const entries = _.uniqBy(result.entries, "id");
1110
1099
  //{
1111
1100
  // id: 144900402,
@@ -1177,8 +1166,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1177
1166
  callGCCallback("partySearch", players);
1178
1167
  break;
1179
1168
  }
1180
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayersProfile: {
1181
- let data = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_PlayersProfile, payload)?.account_profiles;
1169
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_PlayersProfile: {
1170
+ let data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_PlayersProfile).protoDecode(payload)?.account_profiles;
1182
1171
  const dataExample = [
1183
1172
  {
1184
1173
  my_current_event_teams: [],
@@ -1250,8 +1239,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1250
1239
  callEvent(events.playersProfile, player);
1251
1240
  break;
1252
1241
  }
1253
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientLogonFatalError: {
1254
- const data = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientLogonFatalError, payload);
1242
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientLogonFatalError: {
1243
+ const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientLogonFatalError).protoDecode(payload);
1255
1244
  const dataExample = {
1256
1245
  errorcode: 4,
1257
1246
  message: "",
@@ -1260,8 +1249,8 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1260
1249
  callEvent(events.fatalError, data);
1261
1250
  break;
1262
1251
  }
1263
- case Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData: {
1264
- const data = protoDecode(Protos.csgo.CMsgGCCStrike15_v2_ClientRequestJoinFriendData, payload);
1252
+ case ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData: {
1253
+ const data = new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestJoinFriendData).protoDecode(payload);
1265
1254
  if (!data?.account_id) {
1266
1255
  return;
1267
1256
  }
@@ -1278,10 +1267,10 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1278
1267
  }
1279
1268
  default:
1280
1269
  log(`receivedFromGC ${msgType} ${key}`);
1281
- const results = Object.values(Protos.csgo)
1270
+ const results = Object.values(SteamProtoType)
1282
1271
  .map(function (p) {
1283
1272
  try {
1284
- return protoDecode(p, payload);
1273
+ return new SteamProto(p).protoDecode(payload);
1285
1274
  } catch (e) {}
1286
1275
  })
1287
1276
  .filter(function (result) {
@@ -1536,23 +1525,23 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1536
1525
  // });
1537
1526
 
1538
1527
  function getECsgoGCMsgKey(_key) {
1539
- for (let key in Protos.csgo.ECsgoGCMsg) {
1540
- if (Protos.csgo.ECsgoGCMsg[key] == _key) {
1528
+ for (let key in ESteamProto.ECsgoGCMsg) {
1529
+ if (ESteamProto.ECsgoGCMsg[key] == _key) {
1541
1530
  return key;
1542
1531
  }
1543
1532
  }
1544
- for (let key in Protos.csgo.EGCBaseClientMsg) {
1545
- if (Protos.csgo.EGCBaseClientMsg[key] == _key) {
1533
+ for (let key in ESteamProto.EGCBaseClientMsg) {
1534
+ if (ESteamProto.EGCBaseClientMsg[key] == _key) {
1546
1535
  return key;
1547
1536
  }
1548
1537
  }
1549
- for (let key in Protos.csgo.EMsg) {
1550
- if (Protos.csgo.EMsg[key] == _key) {
1538
+ for (let key in ESteamProto.EMsg) {
1539
+ if (ESteamProto.EMsg[key] == _key) {
1551
1540
  return key;
1552
1541
  }
1553
1542
  }
1554
- for (let key in Protos.csgo.EGCItemMsg) {
1555
- if (Protos.csgo.EGCItemMsg[key] == _key) {
1543
+ for (let key in ESteamProto.EGCItemMsg) {
1544
+ if (ESteamProto.EGCItemMsg[key] == _key) {
1556
1545
  return key;
1557
1546
  }
1558
1547
  }
@@ -1608,9 +1597,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1608
1597
  const accountid = new SteamID(steamId).accountid;
1609
1598
  steamClient.sendToGC(
1610
1599
  730,
1611
- Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestPlayersProfile,
1600
+ ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestPlayersProfile,
1612
1601
  {},
1613
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_ClientRequestPlayersProfile, {
1602
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestPlayersProfile).protoEncode({
1614
1603
  account_id: accountid, // account_id: new SteamID('76561199184696945').accountid,
1615
1604
  request_level: 32,
1616
1605
  }),
@@ -1796,12 +1785,12 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1796
1785
  async function init() {
1797
1786
  bindEvent();
1798
1787
  if (await login()) {
1799
- steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
1800
- const result = protoDecode(Protos.csgo.CMsgClientRequestedClientStats, payload.toBuffer());
1788
+ steamClient._handlerManager.add(ESteamProto.EMsg.k_EMsgClientRequestedClientStats, function (payload) {
1789
+ const result = new SteamProto(SteamProtoType.CMsgClientRequestedClientStats).protoDecode(payload.toBuffer());
1801
1790
  // console.log("CMsgClientRequestedClientStats", result);
1802
1791
  });
1803
- steamClient._handlerManager.add(Protos.csgo.EMsg.k_EMsgClientMMSLobbyData, function (payload) {
1804
- const result = protoDecode(Protos.csgo.CMsgClientMMSLobbyData, payload.toBuffer());
1792
+ steamClient._handlerManager.add(ESteamProto.EMsg.k_EMsgClientMMSLobbyData, function (payload) {
1793
+ const result = new SteamProto(SteamProtoType.CMsgClientMMSLobbyData).protoDecode(payload.toBuffer());
1805
1794
  // console.log("CMsgClientMMSLobbyData", result, result.metadata);
1806
1795
  });
1807
1796
  }
@@ -1818,12 +1807,12 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1818
1807
 
1819
1808
  function _partyRegister(prime) {
1820
1809
  log("partyRegister", prime);
1821
- lastTimePartyRegister = new Date().getTime();
1810
+ lastTimePartyRegister = Date.now();
1822
1811
  steamClient.sendToGC(
1823
1812
  730,
1824
- Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Register,
1813
+ ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_Party_Register,
1825
1814
  {},
1826
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_Party_Register, {
1815
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_Party_Register).protoEncode({
1827
1816
  // id : 0,
1828
1817
  ver: CSGO_VER,
1829
1818
  apr: prime ? 1 : 0, //prime
@@ -1835,37 +1824,48 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
1835
1824
  );
1836
1825
  }
1837
1826
 
1838
- async function sendFriendMessage(steamId, message) {
1839
- while (sendMessageTimestamp && new Date().getTime() - sendMessageTimestamp < 2000) {
1840
- await sleep(1000);
1841
- }
1827
+ const MessageQueue = [];
1842
1828
 
1843
- while (isSendingFriendMessages) {
1844
- await sleep(5000);
1829
+ async function _execMessageQueue() {
1830
+ if (isSendingFriendMessages) {
1831
+ return;
1845
1832
  }
1833
+ while (MessageQueue.length) {
1834
+ isSendingFriendMessages = true;
1835
+ const item = MessageQueue.shift();
1836
+ const result = await _sendFriendMessage(item.steamId, item.message);
1837
+ item.callback(result);
1838
+ if (MessageQueue.length) {
1839
+ await sleep(1000);
1840
+ }
1841
+ }
1842
+ isSendingFriendMessages = false;
1843
+ }
1846
1844
 
1847
- isSendingFriendMessages = true;
1848
- const now = new Date().getTime();
1849
- while (new Date().getTime() - now < 2 * 60000) {
1850
- //2 minutes
1851
- const result = await new Promise((resolve) => {
1845
+ async function _sendFriendMessage(steamId, message) {
1846
+ let result = null;
1847
+ for (let i = 0; i < 10; i++) {
1848
+ result = await new Promise((resolve) => {
1852
1849
  steamClient.chat.sendFriendMessage(steamId, message, undefined, function (...arg) {
1853
- sendMessageTimestamp = new Date().getTime();
1854
1850
  resolve(arg);
1855
1851
  });
1856
1852
  });
1857
-
1858
1853
  if (result?.[1]?.server_timestamp) {
1859
- isSendingFriendMessages = false;
1860
1854
  return result?.[1];
1861
1855
  } else if (result?.[0]?.message?.includes?.("RateLimitExceeded")) {
1862
1856
  await sleep(5000);
1863
1857
  } else {
1864
- isSendingFriendMessages = false;
1865
1858
  return result;
1866
1859
  }
1867
1860
  }
1868
- isSendingFriendMessages = false;
1861
+ return result;
1862
+ }
1863
+
1864
+ async function sendFriendMessage(steamId, message) {
1865
+ return new Promise((resolve) => {
1866
+ MessageQueue.push({ steamId, message, callback: resolve });
1867
+ _execMessageQueue();
1868
+ });
1869
1869
  }
1870
1870
 
1871
1871
  async function autoRequestFreeLicense(shouldLog = false, max = 10) {
@@ -2176,9 +2176,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2176
2176
  pushGCCallback(`requestJoinFriendData_${accountID}`, resolve, 30000);
2177
2177
  steamClient.sendToGC(
2178
2178
  AppID,
2179
- Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData,
2179
+ ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRequestJoinFriendData,
2180
2180
  {},
2181
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_ClientRequestJoinFriendData, {
2181
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientRequestJoinFriendData).protoEncode({
2182
2182
  version: version || CSGO_VER,
2183
2183
  account_id: accountID,
2184
2184
  join_token: joinToken,
@@ -2189,21 +2189,21 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2189
2189
  }
2190
2190
 
2191
2191
  function redeemFreeReward(itemIds, generation_time) {
2192
- console.log(`Sent message to GC: AppID ${AppID}, MessageType ${Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward}`);
2192
+ console.log(`Sent message to GC: AppID ${AppID}, MessageType ${ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward}`);
2193
2193
 
2194
- const encodedMessages = protoEncode(Protos.csgo.CMsgGCCstrike15_v2_ClientRedeemFreeReward, {
2194
+ const encodedMessages = new SteamProto(SteamProtoType.CMsgGCCstrike15_v2_ClientRedeemFreeReward).protoEncode({
2195
2195
  items: itemIds,
2196
2196
  redeemable_balance: 0,
2197
2197
  generation_time: generation_time,
2198
2198
  });
2199
- steamClient.sendToGC(730, Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward, {}, encodedMessages, function (payload) {
2199
+ steamClient.sendToGC(730, ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward, {}, encodedMessages, function (payload) {
2200
2200
  console.log(payload);
2201
2201
  });
2202
2202
 
2203
2203
  setTimeout(function () {
2204
2204
  steamClient._send(
2205
2205
  {
2206
- msg: Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward,
2206
+ msg: ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientRedeemFreeReward,
2207
2207
  proto: {
2208
2208
  steamid: steamClient.steamID.getSteamID64(),
2209
2209
  routing_appid: 730,
@@ -2225,13 +2225,13 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2225
2225
 
2226
2226
  steamClient._send(
2227
2227
  {
2228
- msg: Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate,
2228
+ msg: ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_ClientGCRankUpdate,
2229
2229
  proto: {
2230
2230
  steamid: steamClient.steamID.getSteamID64(),
2231
2231
  routing_appid: 730,
2232
2232
  },
2233
2233
  },
2234
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_ClientGCRankUpdate, {
2234
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_ClientGCRankUpdate).protoEncode({
2235
2235
  rankings: [
2236
2236
  {
2237
2237
  rank_type_id: 7, //wing man
@@ -2255,9 +2255,9 @@ function SteamClient({ username, password, cookie, clientJsToken, isAutoRequestF
2255
2255
  function acknowledgePenalty() {
2256
2256
  steamClient.sendToGC(
2257
2257
  730,
2258
- Protos.csgo.ECsgoGCMsg.k_EMsgGCCStrike15_v2_AcknowledgePenalty,
2258
+ ESteamProto.ECsgoGCMsg.k_EMsgGCCStrike15_v2_AcknowledgePenalty,
2259
2259
  {},
2260
- protoEncode(Protos.csgo.CMsgGCCStrike15_v2_AcknowledgePenalty, {
2260
+ new SteamProto(SteamProtoType.CMsgGCCStrike15_v2_AcknowledgePenalty).protoEncode({
2261
2261
  acknowledged: 1,
2262
2262
  }),
2263
2263
  );
@@ -2505,19 +2505,19 @@ SteamClient.isAccountPlayable = async function isAccountPlayable({ cookie, clien
2505
2505
  ...rest,
2506
2506
  });
2507
2507
 
2508
- steamClient.onEvent("error", ({ eresult, msg, error }) => {
2508
+ steamClient.onEvent(SteamClientEvents.error, ({ eresult, msg, error }) => {
2509
2509
  doResolve({ eresult, msg, error });
2510
2510
  });
2511
2511
 
2512
- steamClient.onEvent("csgoOnline", (ClientWelcome) => {
2512
+ steamClient.onEvent(SteamClientEvents.csgoOnline, (ClientWelcome) => {
2513
2513
  doResolve({ playable: true });
2514
2514
  });
2515
2515
 
2516
- steamClient.onEvent("csgoClientHello", (ClientHello) => {
2516
+ steamClient.onEvent(SteamClientEvents.csgoClientHello, (ClientHello) => {
2517
2517
  doResolve({ playable: true });
2518
2518
  });
2519
2519
 
2520
- steamClient.onEvent("playingState", ({ playing_blocked, playing_app }) => {
2520
+ steamClient.onEvent(SteamClientEvents.playingState, ({ playing_blocked, playing_app }) => {
2521
2521
  if (playing_blocked) {
2522
2522
  doResolve({ playable: false });
2523
2523
  } else {