A node-steam plugin for Dota 2, consider it in alpha state.
Check out @RJacksonm1's blog post (his only blog post), Extending node-dota2, for a rough overview of adding new functionality to the library. A fair warning, while the way you search for new functionality is still the same, quite a lot has changed (and been simplified) implementation wise. It is now easier to implement new functionality than it was back when this blog was written.
npm installin the repository root- Copy
config.js.exampletoconfig.jsand edit appropriately - Run the example script:
node example.js - If you receive Error 63 you need to provide a Steam Guard code by setting the Steam Guard code in
config.jsand launching again. - Make sure to use at least version 4.4.5 of node js
Parameters:
steamClient- Pass a SteamClient instance to use to send & receive GC messages.debug- A boolean noting whether to print information about operations to console.debugMore- A boolean noting whether to print extended debug information. Activating this will log messages for each proto message exchanged with the GC.
var Steam = require('steam'),
steamClient = new Steam.SteamClient(),
dota2 = require('dota2'),
Dota2 = new dota2.Dota2Client(steamClient, true, false);We do not in any way encourage people to use their own accounts when using this library. This library tries to mimic the behavior of the Dota 2 client to allow people to programmatically interact with the Dota 2 GC, however we make no efforts to hide this fact and it's pretty easy for Valve to detect clients using this library based on the generated traffic. While Valve has not yet expressed a dislike regarding reverse engineering projects like this one, it's not unimaginable that this might one day change and result in VAC bans.
The examples directory contains two Dota2 bots as an example. One contains commented-out dota2 methods, the other has boolean activated methods.
Both examples show how to interact with the library.
There is a partial automated test suite for node-dota2, which is located in the test directory.
You need to configure the STEAM_USERNAME and STEAM_PASSWORD environment variables to be able to run it.
You can launch the tests by running the file with mocha.
The API doc can be consulted here or at doclets.io
Dota 2 module
- Dota2
- static
- .Dota2Client ⇐
EventEmitter- new Dota2.Dota2Client(steamClient, debug, debugMore)
- instance
- .Logger :
winston.Logger - .Inventory :
Array.<CSOEconItem> - .chatChannels :
Array.<CMsgDOTAJoinChatChannelResponse> - .Lobby :
CSODOTALobby - .LobbyInvite :
CSODOTALobbyInvite - .Party :
CSODOTAParty - .PartyInvite :
CSODOTAPartyInvite - .launch()
- .exit()
- "ready"
- "unhandled" (kMsg, kMsg_name)
- "hellotimeout"
- .Logger :
- static
- .ToAccountID(steamID) ⇒
number - .ToSteamID(accid) ⇒
Long
- .ToAccountID(steamID) ⇒
- .schema
- .Dota2Client ⇐
- inner
- static
Kind: static class of Dota2
Extends: EventEmitter
Emits: ready, unhandled, hellotimeout, module:Dota2.Dota2Client#event:popup, module:Dota2.Dota2Client#event:sourceTVGamesData, module:Dota2.Dota2Client#event:inventoryUpdate, module:Dota2.Dota2Client#event:practiceLobbyUpdate, module:Dota2.Dota2Client#event:practiceLobbyCleared, module:Dota2.Dota2Client#event:lobbyInviteUpdate, module:Dota2.Dota2Client#event:lobbyInviteCleared, module:Dota2.Dota2Client#event:practiceLobbyJoinResponse, module:Dota2.Dota2Client#event:practiceLobbyListData, module:Dota2.Dota2Client#event:practiceLobbyResponse, module:Dota2.Dota2Client#event:lobbyDestroyed, module:Dota2.Dota2Client#event:friendPracticeLobbyListData, module:Dota2.Dota2Client#event:inviteCreated, module:Dota2.Dota2Client#event:partyUpdate, module:Dota2.Dota2Client#event:partyCleared, module:Dota2.Dota2Client#event:partyInviteUpdate, module:Dota2.Dota2Client#event:partyInviteCleared, module:Dota2.Dota2Client#event:joinableCustomGameModes, module:Dota2.Dota2Client#event:chatChannelsData, module:Dota2.Dota2Client#event:chatJoin, module:Dota2.Dota2Client#event:chatJoined, module:Dota2.Dota2Client#event:chatLeave, module:Dota2.Dota2Client#event:chatMessage, module:Dota2.Dota2Client#event:profileCardData, module:Dota2.Dota2Client#event:playerMatchHistoryData, module:Dota2.Dota2Client#event:playerInfoData, module:Dota2.Dota2Client#event:playerStatsData, module:Dota2.Dota2Client#event:trophyListData, module:Dota2.Dota2Client#event:hallOfFameData, module:Dota2.Dota2Client#event:playerCardRoster, module:Dota2.Dota2Client#event:playerCardDrafted, module:Dota2.Dota2Client#event:liveLeagueGamesUpdate, module:Dota2.Dota2Client#event:leagueData, module:Dota2.Dota2Client#event:topLeagueMatchesData, module:Dota2.Dota2Client#event:teamData, module:Dota2.Dota2Client#event:matchesData, module:Dota2.Dota2Client#event:matchDetailsData, module:Dota2.Dota2Client#event:matchMinimalDetailsData, module:Dota2.Dota2Client#event:matchmakingStatsData, module:Dota2.Dota2Client#event:topFriendMatchesData, module:Dota2.Dota2Client#event:tipResponse, module:Dota2.Dota2Client#event:tipped
- .Dota2Client ⇐
EventEmitter- new Dota2.Dota2Client(steamClient, debug, debugMore)
- instance
- .Logger :
winston.Logger - .Inventory :
Array.<CSOEconItem> - .chatChannels :
Array.<CMsgDOTAJoinChatChannelResponse> - .Lobby :
CSODOTALobby - .LobbyInvite :
CSODOTALobbyInvite - .Party :
CSODOTAParty - .PartyInvite :
CSODOTAPartyInvite - .launch()
- .exit()
- "ready"
- "unhandled" (kMsg, kMsg_name)
- "hellotimeout"
- .Logger :
- static
- .ToAccountID(steamID) ⇒
number - .ToSteamID(accid) ⇒
Long
- .ToAccountID(steamID) ⇒
The Dota 2 client that communicates with the GC
| Param | Type | Description |
|---|---|---|
| steamClient | Object |
Node-steam client instance |
| debug | boolean |
Print debug information to console |
| debugMore | boolean |
Print even more debug information to console |
The logger used to write debug messages. This is a WinstonJS logger, feel free to configure it as you like
Kind: instance property of Dota2Client
The current state of the bot's inventory. Contains cosmetics, player cards, ...
Kind: instance property of Dota2Client
The chat channels the bot has joined
Kind: instance property of Dota2Client
The lobby the bot is currently in. Falsy if the bot isn't in a lobby.
Kind: instance property of Dota2Client
The currently active lobby invitation. Falsy if the bot has not been invited.
Kind: instance property of Dota2Client
The party the bot is currently in. Falsy if the bot isn't in a party.
Kind: instance property of Dota2Client
The currently active party invitation. Falsy if the bot has not been invited.
Kind: instance property of Dota2Client
Reports to Steam that you're playing Dota 2, and then initiates communication with the Game Coordinator.
Kind: instance method of Dota2Client
Stop sending a heartbeat to the GC and report to steam you're no longer playing Dota 2
Kind: instance method of Dota2Client
Emitted when the connection with the GC has been established and the client is ready to take requests.
Kind: event emitted by Dota2Client
Emitted when the GC sends a message that isn't yet treated by the library.
Kind: event emitted by Dota2Client
| Param | Type | Description |
|---|---|---|
| kMsg | number |
Proto message type ID |
| kMsg_name | string |
Proto message type name |
Emitted when the connection with the GC takes longer than 30s
Kind: event emitted by Dota2Client
Converts a 64bit Steam ID to a Dota2 account ID by deleting the 32 most significant bits
Kind: static method of Dota2Client
Returns: number - Dota2 account ID corresponding with steamID
| Param | Type | Description |
|---|---|---|
| steamID | string |
String representation of a 64bit Steam ID |
Dota2Client.ToSteamID(accid) ⇒ Long
Converts a Dota2 account ID to a 64bit Steam ID
Kind: static method of Dota2Client
Returns: Long - 64bit Steam ID corresponding to the given Dota 2 account ID
| Param | Type | Description |
|---|---|---|
| accid | string |
String representation of a Dota 2 account ID |
Protobuf schema. See Protobufjs#Root.
This object can be used to obtain special protobuf types.
Object types can be created by Dota2.schema.lookupType("TypeName").encode(payload :Object).finish();.
Enum types can be referenced by Dota2.schema.lookupEnum("EnumName").values, which returns an object array representing the enum.
Kind: static property of Dota2
A Long class for representing a 64 bit two's-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.