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,mBACR,QAAQ,qBACR,QAAQ,sBACR,QAAQ,sBACR,QAAQ","file":"/npm/korupt-dota2@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/korupt-dota2@1.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Dota 2 module\n * @module Dota2\n */\n\n/**\n * A Long class for representing a 64 bit two's-complement integer value \n * derived from the Closure Library for stand-alone use and extended with unsigned support.\n * @external Long\n * @see {@link https://www.npmjs.com/package/long|long} npm package\n */\n \n/**\n * The Steam for Node JS package, allowing interaction with Steam.\n * @external steam\n * @see {@link https://www.npmjs.com/package/steam|steam} npm package\n */\n\nconst util = require(\"util\");\nconst Long = require(\"long\");\nconst steam = require(\"steam\");\nconst steam_resources = require(\"steam-resources\");\nconst { createLogger, format, transports } = require('winston');\nconst { EventEmitter } = require('events');\n\nconst DOTA_APP_ID = 570;\n\nvar Dota2 = exports;\n\n/**\n * Protobuf schema created by Steam Resources. This is an alias of `steam.GC.Dota.Internal`.\n * This object can be used to obtain Dota2 specific protobuf types.\n * Object types can be created by `new Dota2.schema.<TypeName>(payload :Object);`.\n * Enum types can be referenced by `Dota2.schema.<EnumName>`, which returns an object array representing the enum.\n * @alias module:Dota2.schema\n */ \nDota2.schema = steam_resources.GC.Dota.Internal;\n\n/**\n * The Dota 2 client that communicates with the GC\n * @class \n * @alias module:Dota2.Dota2Client\n * @param {Object} steamClient - Node-steam client instance\n * @param {boolean} debug - Print debug information to console\n * @param {boolean} debugMore - Print even more debug information to console\n * @extends {EventEmitter} EventEmitter\n * @fires module:Dota2.Dota2Client#event:ready\n * @fires module:Dota2.Dota2Client#event:unhandled\n * @fires module:Dota2.Dota2Client#event:hellotimeout\n * @fires module:Dota2.Dota2Client#event:popup\n * @fires module:Dota2.Dota2Client#event:sourceTVGamesData\n * @fires module:Dota2.Dota2Client#event:inventoryUpdate\n * @fires module:Dota2.Dota2Client#event:practiceLobbyUpdate\n * @fires module:Dota2.Dota2Client#event:practiceLobbyCleared\n * @fires module:Dota2.Dota2Client#event:lobbyInviteUpdate\n * @fires module:Dota2.Dota2Client#event:lobbyInviteCleared\n * @fires module:Dota2.Dota2Client#event:practiceLobbyJoinResponse\n * @fires module:Dota2.Dota2Client#event:practiceLobbyListData\n * @fires module:Dota2.Dota2Client#event:practiceLobbyResponse\n * @fires module:Dota2.Dota2Client#event:lobbyDestroyed\n * @fires module:Dota2.Dota2Client#event:friendPracticeLobbyListData\n * @fires module:Dota2.Dota2Client#event:inviteCreated\n * @fires module:Dota2.Dota2Client#event:partyUpdate\n * @fires module:Dota2.Dota2Client#event:partyCleared\n * @fires module:Dota2.Dota2Client#event:partyInviteUpdate\n * @fires module:Dota2.Dota2Client#event:partyInviteCleared\n * @fires module:Dota2.Dota2Client#event:joinableCustomGameModes\n * @fires module:Dota2.Dota2Client#event:chatChannelsData\n * @fires module:Dota2.Dota2Client#event:chatJoin\n * @fires module:Dota2.Dota2Client#event:chatJoined\n * @fires module:Dota2.Dota2Client#event:chatLeave\n * @fires module:Dota2.Dota2Client#event:chatMessage\n * @fires module:Dota2.Dota2Client#event:profileCardData\n * @fires module:Dota2.Dota2Client#event:playerMatchHistoryData\n * @fires module:Dota2.Dota2Client#event:playerInfoData\n * @fires module:Dota2.Dota2Client#event:playerStatsData\n * @fires module:Dota2.Dota2Client#event:trophyListData\n * @fires module:Dota2.Dota2Client#event:hallOfFameData\n * @fires module:Dota2.Dota2Client#event:playerCardRoster\n * @fires module:Dota2.Dota2Client#event:playerCardDrafted\n * @fires module:Dota2.Dota2Client#event:liveLeagueGamesUpdate\n * @fires module:Dota2.Dota2Client#event:topLeagueMatchesData\n * @fires module:Dota2.Dota2Client#event:teamData\n * @fires module:Dota2.Dota2Client#event:matchesData\n * @fires module:Dota2.Dota2Client#event:matchDetailsData\n * @fires module:Dota2.Dota2Client#event:matchMinimalDetailsData\n * @fires module:Dota2.Dota2Client#event:matchmakingStatsData\n * @fires module:Dota2.Dota2Client#event:topFriendMatchesData\n * @fires module:Dota2.Dota2Client#event:tipResponse\n * @fires module:Dota2.Dota2Client#event:tipped\n */\nDota2.Dota2Client = function Dota2Client(steamClient, debug, debugMore) {\n    EventEmitter.call(this);\n    this.debug = debug || false;\n    this.debugMore = debugMore || false;\n    \n    /**\n     * The logger used to write debug messages. This is a WinstonJS logger, \n     * feel free to configure it as you like\n     * @type {winston.Logger}\n     */\n    this.Logger = createLogger({\n        transports: [new transports.Console()],\n        format: format.combine(\n            format.colorize(),\n            format.timestamp({\n                format: 'D MMM HH:mm:ss'\n            }),\n            format.printf(nfo => {\n                return `${nfo.timestamp} - ${nfo.message}`\n            })\n        )\n    });\n    if(debug) this.Logger.level = \"debug\";\n    if(debugMore) this.Logger.level = \"silly\";\n    \n    /** The current state of the bot's inventory. Contains cosmetics, player cards, ... \n     * @type {CSOEconItem[]} \n     */\n    this.Inventory = [];\n    /** The chat channels the bot has joined \n     * @type {CMsgDOTAJoinChatChannelResponse[]}\n     */\n    this.chatChannels = []; // Map channel names to channel data.\n    /** The lobby the bot is currently in. Falsy if the bot isn't in a lobby. \n     * @type {CSODOTALobby}\n     */\n    this.Lobby = null;\n    /** The currently active lobby invitation. Falsy if the bot has not been invited. \n     * @type {CSODOTALobbyInvite}\n     */\n    this.LobbyInvite = null;\n    /** The party the bot is currently in. Falsy if the bot isn't in a party.\n    * @type {CSODOTAParty}\n    */\n    this.Party = null;\n    /** The currently active party invitation. Falsy if the bot has not been invited.\n     * @type {CSODOTAPartyInvite}\n     */\n    this.PartyInvite = null;\n\n    var steamUser = new steam.SteamUser(steamClient);\n    this._user = steamUser;\n    this._client = steamClient;\n    this._gc = new steam.SteamGameCoordinator(steamClient, DOTA_APP_ID);\n    this._appid = DOTA_APP_ID;\n    \n    this._gcReady = false;\n    this._gcClientHelloIntervalId = null;\n    this._gcConnectionStatus = Dota2.schema.GCConnectionStatus.GCConnectionStatus_NO_SESSION;\n    // node-steam wants this as a simple object, so we can't use CMsgProtoBufHeader\n    this._protoBufHeader = {\n        \"msg\": \"\",\n        \"proto\": {\n            \"client_steam_id\": this._client.steamID,\n            \"source_app_id\": this._appid\n        }\n    };\n\n    var self = this;\n    this._gc.on(\"message\", function fromGC(header, body, callback) {\n        /* Routes messages from Game Coordinator to their handlers. */\n        callback = callback || null;\n\n        var kMsg = header.msg;\n        self.Logger.silly(\"Dota2 fromGC: \" + Dota2._getMessageName(kMsg));\n\n        if (kMsg in self._handlers) {\n            if (callback) {\n                self._handlers[kMsg].call(self, body, callback);\n            } else {\n                self._handlers[kMsg].call(self, body);\n            }\n        } else {\n            self.emit(\"unhandled\", kMsg, Dota2._getMessageName(kMsg));\n        }\n    });\n\n    this._sendClientHello = function() {\n        if (self._gcReady) {\n            if (self._gcClientHelloIntervalId) {\n                clearInterval(self._gcClientHelloIntervalId);\n                self._gcClientHelloIntervalId = null;\n            }\n            return;\n        }\n        if (self._gcClientHelloCount > 10) {\n            self.Logger.warn(\"ClientHello has taken longer than 30 seconds! Reporting timeout...\")\n            self._gcClientHelloCount = 0;\n            self.emit(\"hellotimeout\");\n        }\n        \n        self.Logger.debug(\"Sending ClientHello\");\n        \n        if (!self._gc) {\n            self.Logger.error(\"Where the fuck is _gc?\");\n        } else {\n            self._gc.send(\n                {msg: Dota2.schema.EGCBaseClientMsg.k_EMsgGCClientHello, proto: {}},\n                new Dota2.schema.CMsgClientHello({}).toBuffer()\n            );\n        }\n\n        self._gcClientHelloCount++;\n    };\n};\nutil.inherits(Dota2.Dota2Client, EventEmitter);\n\n// Methods\n/**\n * Converts a 64bit Steam ID to a Dota2 account ID by deleting the 32 most significant bits\n * @alias module:Dota2.Dota2Client.ToAccountID\n * @param {string} steamID - String representation of a 64bit Steam ID\n * @returns {number} Dota2 account ID corresponding with steamID\n */\nDota2.Dota2Client.prototype.ToAccountID = function(steamID) {\n    return new Long.fromString(\"\"+steamID).sub('76561197960265728').toNumber();\n};\n/**\n * Converts a Dota2 account ID to a 64bit Steam ID\n * @alias module:Dota2.Dota2Client.ToSteamID\n * @param {string} accid - String representation of a Dota 2 account ID\n * @returns {external:Long} 64bit Steam ID corresponding to the given Dota 2 account ID\n */\nDota2.Dota2Client.prototype.ToSteamID = function(accid) {\n    return new Long.fromString(accid+\"\").add('76561197960265728');\n};\n/**\n * Reports to Steam that you're playing Dota 2, and then initiates communication with the Game Coordinator.\n * @alias module:Dota2.Dota2Client#launch\n */\nDota2.Dota2Client.prototype.launch = function() {\n    /* Reports to Steam that we are running Dota 2. Initiates communication with GC with EMsgGCClientHello */\n    this.Logger.debug(\"Launching Dota 2\");\n    \n    this.AccountID = this.ToAccountID(this._client.steamID);\n    this.Party = null;\n    this.Lobby = null;\n    this.PartyInvite = null;\n    this.Inventory = [];\n    this.chatChannels = [];\n    this._user.gamesPlayed([{\n        \"game_id\": this._appid\n    }]);\n\n    // Keep knocking on the GCs door until it accepts us.\n    // This is very bad practice and quite trackable.\n    // The real client tends to send only one of these.\n    // Really we should just send one when the connection status is GC online\n    this._gcClientHelloCount = 0;\n    this._gcClientHelloIntervalId = setInterval(this._sendClientHello, 6000);\n\n    //Also immediately send clienthello\n    setTimeout(this._sendClientHello, 1000);\n};\n/**\n * Stop sending a heartbeat to the GC and report to steam you're no longer playing Dota 2\n * @alias module:Dota2.Dota2Client#exit\n */\nDota2.Dota2Client.prototype.exit = function() {\n    /* Reports to Steam we are not running any apps. */\n    this.Logger.debug(\"Exiting Dota 2\");\n\n    /* stop knocking if exit comes before ready event */\n    if (this._gcClientHelloIntervalId) {\n        clearInterval(this._gcClientHelloIntervalId);\n        this._gcClientHelloIntervalId = null;\n    }\n    this._gcReady = false;\n\n    if (this._client.loggedOn) this._user.gamesPlayed([]);\n};\n\nDota2.Dota2Client.prototype.sendToGC = function(type, payload, handler, callback) {\n    var self = this;\n    if (!this._gcReady) {\n        this.Logger.warn(\"GC not ready, please listen for the 'ready' event.\");\n        if (callback) callback(-1, null);                   // notify user that something went wrong\n        return null;\n    }\n    this._protoBufHeader.msg = type;\n    this._gc.send(this._protoBufHeader,                                // protobuf header, same for all messages\n                  payload.toBuffer(),                                  // payload of the message\n                  Dota2._convertCallback.call(self, handler, callback) // let handler treat callback so events are triggered\n    );\n}\n\n// Events\n/**\n * Emitted when the connection with the GC has been established \n * and the client is ready to take requests.\n * @event module:Dota2.Dota2Client#ready\n */\n/**\n * Emitted when the GC sends a message that isn't yet treated by the library.\n * @event module:Dota2.Dota2Client#unhandled\n * @param {number} kMsg - Proto message type ID\n * @param {string} kMsg_name - Proto message type name\n */\n/**\n * Emitted when the connection with the GC takes longer than 30s\n * @event module:Dota2.Dota2Client#hellotimeout\n */\n\n// Handlers\n\nvar handlers = Dota2.Dota2Client.prototype._handlers = {};\n\nhandlers[Dota2.schema.EGCBaseClientMsg.k_EMsgGCClientWelcome] = function clientWelcomeHandler(message) {\n    /* Response to our k_EMsgGCClientHello, now we can execute other GC commands. */\n\n    // Only execute if _gcClientHelloIntervalID, otherwise it's already been handled (and we don't want to emit multiple 'ready');\n    if (this._gcClientHelloIntervalId) {\n        clearInterval(this._gcClientHelloIntervalId);\n        this._gcClientHelloIntervalId = null;\n    }\n\n    this.Logger.debug(\"Received client welcome.\");\n\n    // Parse any caches\n    this._gcReady = true;\n    this._handleWelcomeCaches(message);\n    this.emit(\"ready\");\n};\n\nhandlers[Dota2.schema.EGCBaseClientMsg.k_EMsgGCClientConnectionStatus] = function gcClientConnectionStatus(message) {\n    /* Catch and handle changes in connection status, cuz reasons u know. */\n    var status = Dota2.schema.CMsgConnectionStatus.decode(message).status;\n    \n    if (status) this._gcConnectionStatus = status;\n\n    switch (status) {\n        case Dota2.schema.GCConnectionStatus.GCConnectionStatus_HAVE_SESSION:\n            this.Logger.debug(\"GC Connection Status regained.\");\n\n            // Only execute if _gcClientHelloIntervalID, otherwise it's already been handled (and we don't want to emit multiple 'ready');\n            if (this._gcClientHelloIntervalId) {\n                clearInterval(this._gcClientHelloIntervalId);\n                this._gcClientHelloIntervalId = null;\n\n                this._gcReady = true;\n                this.emit(\"ready\");\n            }\n            break;\n\n        default:\n            this.Logger.debug(Object.keys(Dota2.schema.GCConnectionStatus).find(key => Dota2.schema.GCConnectionStatus[key] === status));\n            \n            this.Logger.debug(\"GC Connection Status unreliable - \" + status);\n\n            // Only execute if !_gcClientHelloIntervalID, otherwise it's already been handled (and we don't want to emit multiple 'unready');\n            if (!this._gcClientHelloIntervalId) {\n                this._gcClientHelloIntervalId = setInterval(this._sendClientHello, 5000); // Continually try regain GC session\n\n                this._gcReady = false;\n                this.emit(\"unready\");\n            }\n            break;\n    }\n};\n\n\nrequire(\"./handlers/cache\");\nrequire(\"./handlers/inventory\");\nrequire(\"./handlers/chat\");\nrequire(\"./handlers/guild\");\nrequire(\"./handlers/community\");\nrequire(\"./handlers/helper\");\nrequire(\"./handlers/match\");\nrequire(\"./handlers/lobbies\");\nrequire(\"./handlers/parties\");\nrequire(\"./handlers/leagues\");\nrequire(\"./handlers/sourcetv\");\nrequire(\"./handlers/team\");\nrequire(\"./handlers/custom\");\nrequire(\"./handlers/general\");\nrequire(\"./handlers/fantasy\");\nrequire(\"./handlers/compendium\");"]}