7.0.3 • Published 5 years ago

dota2 v7.0.3

Weekly downloads
191
License
MIT
Repository
github
Last release
5 years ago

node-dota2

NPM version Build Status Dependency Status Greenkeeper badge

A node-steam plugin for Dota 2, consider it in alpha state.

Contributing

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.

Be careful, you'll need SVN if you want to work on the project! Executing an npm install inside the project directory has node-steam fetch the most recent node-steam-resources, which needs SVN to obtain the protobufs.

Installation and setup

  • npm install dota2 in your repository root
  • Copy node_modules/dota2/examples/config.js.example to config.js in your project root and edit appropriately
  • Copy node_modules/dota2/examples/example.js in your project root and change line 5 to dota2 = require("dota2"),
  • 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.js and launching again.
  • Make sure to use at least version 4.4.5 of node js

WARNING

At the moment the serverlist that is kept internally by node-steam contains IP addresses which are no longer responsive. This causes timeouts and makes node-dota2 seem unresponsive. The examples contain a fix for this behaviour. In short, node-steam emits a servers event that will always contain the latest version of the server list. You need to make sure that your bot handles this event and saves its contents so that upon next startup you can initialize node-steam with a more up to date list. The examples folder contains a (as of the beginning of October 2018) working list that is read by the example bots. You can use this list to bootstrap your bot until node-steam updates their embedded list.

Initializing

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);

Disclaimer

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.

Examples

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.

Testing

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.

API

The API doc can be consulted here or at doclets.io

Dota2

Dota 2 module

Dota2.Dota2Client ⇐ EventEmitter

Kind: static class of Dota2
Extends: EventEmitter
Emits: ready, unhandled, hellotimeout, popup, sourceTVGamesData, inventoryUpdate, practiceLobbyUpdate, practiceLobbyCleared, lobbyInviteUpdate, lobbyInviteCleared, practiceLobbyJoinResponse, practiceLobbyListData, practiceLobbyResponse, lobbyDestroyed, friendPracticeLobbyListData, inviteCreated, partyUpdate, partyCleared, partyInviteUpdate, partyInviteCleared, joinableCustomGameModes, chatChannelsData, chatJoin, chatJoined, chatLeave, chatMessage, profileCardData, playerMatchHistoryData, playerInfoData, playerStatsData, trophyListData, hallOfFameData, playerCardRoster, playerCardDrafted, liveLeagueGamesUpdate, topLeagueMatchesData, teamData, matchesData, matchDetailsData, matchMinimalDetailsData, matchmakingStatsData, topFriendMatchesData, tipResponse, tipped

new Dota2.Dota2Client(steamClient, debug, debugMore)

The Dota 2 client that communicates with the GC

ParamTypeDescription
steamClientObjectNode-steam client instance
debugbooleanPrint debug information to console
debugMorebooleanPrint even more debug information to console

dota2Client.Logger : winston.Logger

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

dota2Client.Inventory : Array.<CSOEconItem>

The current state of the bot's inventory. Contains cosmetics, player cards, ...

Kind: instance property of Dota2Client

dota2Client.chatChannels : Array.<CMsgDOTAJoinChatChannelResponse>

The chat channels the bot has joined

Kind: instance property of Dota2Client

dota2Client.Lobby : CSODOTALobby

The lobby the bot is currently in. Falsy if the bot isn't in a lobby.

Kind: instance property of Dota2Client

Lobby.Options : Object

Kind: static typedef of Lobby
Properties

NameTypeDefaultDescription
game_namestringName of the lobby
pass_keystringLobby password
server_regionServerRegionmodule:Dota2.ServerRegion.UNSPECIFIEDServer region where the lobby will be created
game_modeDOTA_GameModeDOTA_GameMode.DOTA_GAMEMODE_APGame mode
game_versionDOTAGameVersionDOTAGameVersion.GAME_VERSION_STABLEVersion of the game
cm_pickDOTA_CM_PICKDOTA_CM_PICK.DOTA_CM_RANDOMWho gets first pick
allow_cheatsbooleanfalseWhether or not to allow cheats
fill_with_botsbooleanfalseWhether or not to fill empty slots with bots
bot_difficulty_radiantBotDifficultymodule:Dota2.schema.DOTABotDifficulty.BOT_DIFFICULTY_PASSIVEThe bot difficulty for radiant bots, if fill_with_bots is true.
bot_difficulty_direBotDifficultymodule:Dota2.schema.DOTABotDifficulty.BOT_DIFFICULTY_PASSIVEThe bot difficulty for dire bots, if fill_with_bots is true.
bot_radiantnumberPresumably the ID of the custom AI to be applied to radiant bots.
bot_direnumberPresumably the ID of the custom AI to be applied to dire bots.
allow_spectatingbooleantrueWhether or not to allow spectating
series_typeSeriesTypeNONEWhether or not the game is part of a series (Bo3, Bo5).
radiant_series_winsnumber0# of games won so far, e.g. for a Bo3 or Bo5.
dire_series_winsnumber0# of games won so far, e.g. for a Bo3 or Bo5.
previous_match_overridenumberIn a series, the match ID of the previous game. If not supplied, the GC will try to find it automatically based on the teams and the players.
allchatbooleanfalseWhether or not it's allowed to all-chat
dota_tv_delayLobbyDotaTVDelayLobbyDotaTV_120How much time the game should be delayed for DotaTV.
leagueidnumberThe league this lobby is being created for. The bot should be a league admin for this to work.
custom_game_modestringName of the custom game
custom_map_namestringWhich map the custom game should be played on
custom_difficultynumberDifficulty of the custom game
custom_game_idLong64bit ID of the custom game mode
pause_settingLobbyDotaPauseSetting0Pause setting: 0 - unlimited, 1 - limited, 2 - disabled

dota2Client.LobbyInvite : CSODOTALobbyInvite

The currently active lobby invitation. Falsy if the bot has not been invited.

Kind: instance property of Dota2Client

dota2Client.Party : CSODOTAParty

The party the bot is currently in. Falsy if the bot isn't in a party.

Kind: instance property of Dota2Client

dota2Client.PartyInvite : CSODOTAPartyInvite

The currently active party invitation. Falsy if the bot has not been invited.

Kind: instance property of Dota2Client

dota2Client.launch()

Reports to Steam that you're playing Dota 2, and then initiates communication with the Game Coordinator.

Kind: instance method of Dota2Client

dota2Client.exit()

Stop sending a heartbeat to the GC and report to steam you're no longer playing Dota 2

Kind: instance method of Dota2Client

dota2Client.joinChat(channel_name, channel_type)

Joins a chat channel. If the chat channel with the given name doesn't exist, it is created. Listen for the chatMessage event for other people's chat messages. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDefaultDescription
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tDOTAChatChannelType_t.DOTAChatChannelType_CustomThe type of the channel being joined

dota2Client.leaveChat(channel_name, channel_type)

Leaves a chat channel. If you've joined different channels with the same name, specify the type to prevent unexpected behaviour. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tThe type of the channel being joined

dota2Client.sendMessage(message, channel_name, channel_type)

Sends a message to the specified chat channel. Won't send if you're not in the channel you try to send to. If you've joined different channels with the same name, specify the type to prevent unexpected behaviour. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
messagestringThe message you want to send
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tThe type of the channel being joined

dota2Client.shareLobby(channel_name, channel_type)

Shares the lobby you're currently in with the chat so other people can join. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tThe type of the channel being joined

dota2Client.flipCoin(channel_name, channel_type)

Sends a coin flip to the specified chat channel. Won't send if you're not in the channel you try to send to. If you've joined different channels with the same name, specify the type to prevent unexpected behaviour. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tThe type of the channel being joined

dota2Client.rollDice(min, max, channel_name, channel_type)

Sends a dice roll to the specified chat channel. Won't send if you're not in the channel you try to send to. If you've joined different channels with the same name, specify the type to prevent unexpected behaviour. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
minnumberLower bound of the dice roll
maxnumberUpper bound of the dice roll
channel_namestringName of the chat channel
channel_typeDOTAChatChannelType_tThe type of the channel being joined

dota2Client.requestChatChannels()

Requests a list of chat channels from the GC. Listen for the chatChannelsData event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

dota2Client.requestPlayerMatchHistory(account_id, options, callback)

Requests the given player's match history. The responses are paginated, but you can use the start_at_match_id and matches_requested options to loop through them. Provide a callback or listen for the playerMatchHistoryData event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDefaultDescription
account_idnumberDota 2 account ID of the player whose match history the bot should fetch
optionsObjectFiltering options
options.start_at_match_idnumberWhich match ID to start searching at (pagination)
options.matches_requestednumberHow many matches to retrieve
options.hero_idnumberShow only matches where player played the given hero
options.request_idnumberaccount_idA unique identifier that identifies this request
options.include_practice_matchesbooleanWhether or not to include practice matches in the results
options.include_custom_gamesbooleanWhether or not to include custom games in the results
callbackrequestCallbackCalled with err, CMsgDOTAGetPlayerMatchHistoryResponse

dota2Client.requestProfileCard(account_id, callback)

Sends a message to the Game Coordinator requesting account_id's profile card. This method is heavily rate limited. When abused, the GC just stops responding. Even the regular client runs into this limit when you check too many profiles. Provide a callback or listen for profileCardData event for Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberDota 2 account ID of the player whose profile card the bot should fetch
callbackrequestCallbackCalled with err, CMsgDOTAProfileCard

dota2Client.requestProfile(account_id, callback)

Sends a message to the Game Coordinator requesting account_id's profile page. This method is heavily rate limited. When abused, the GC just stops responding. Even the regular client runs into this limit when you check too many profiles. Provide a callback or listen for profileData event for Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberDota 2 account ID of the player whose profile page the bot should fetch
callbackrequestCallbackCalled with err, CMsgDOTAProfileResponse

dota2Client.requestHallOfFame(week, callback)

Sends a message to the Game Coordinator requesting the Hall of Fame data for week. Provide a callback or listen for the hallOfFameData event for the Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
weeknumberThe week of which you wish to know the Hall of Fame members; will return latest week if omitted. Weeks are counted from start of unix epoch with a lower bound of 2233 (2012-10-18)
callbackrequestCallbackCalled with err, CMsgDOTAHallOfFameResponse

dota2Client.requestPlayerInfo(account_ids)

Sends a message to the Game Coordinator requesting one or multiple account_ids player information. This includes their display name, country code, team info and sponsor, fantasy role, official information lock status, and if the user is marked as a pro player. Listen for the playerInfoData event for the Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idsnumber | Array.<number>Either a single or array of Account IDs (lower 32-bits of a 64-bit Steam ID) of desired user(s) player info.

dota2Client.requestTrophyList(account_id, callback)

Sends a message to the Game Coordinator requesting account_id's trophy data. Provide a callback or listen for trophyListData event for Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberDota 2 account ID of the player whose trophy data the bot should fetch
callbackrequestCallbackCalled with err, CMsgClientToGCGetTrophyListResponse

dota2Client.requestPlayerStats(account_id, callback)

Sends a message to the Game Coordinator requesting account_id's player stats. Provide a callback or listen for playerStatsData event for Game Coordinator's response. This data contains all stats shown on a player's profile page. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberDota 2 account ID of the player whose player stats the bot should fetch
callbackrequestCallbackCalled with err, CMsgGCToClientPlayerStatsResponse

dota2Client.tipPlayer(account_id, steam_id, steam_id)

Attempts to tip a player for his performance during a match. Listen for the tipResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberThe Dota2 ID of the player you want to tip.
steam_idLongThe match ID for which you want to tip a player.
steam_idnumberThe event ID during which you want to tip a player.

dota2Client.requestJoinableCustomGameModes(server_region)

Requests a list of custom game modes for which there are currently lobbies available. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDefaultDescription
server_regionServerRegionServerRegion.UNSPECIFIEDThe server region for which you'd like to obtain the joinable custom game modes

dota2Client.requestPlayerCardsByPlayer() ⇒ Array.<FantasyPlayer>

Requests the player stats for each of the players for which you have one or multiple player cards. All requests are staggered in 200ms intervals and time out after 2s. Requires the GC to be ready.

Kind: instance method of Dota2Client

requestPlayerCardsByPlayer.FantasyPlayer : Object

Player with player cards

Kind: static typedef of requestPlayerCardsByPlayer
Properties

NameTypeDescription
account_idnumberDota2 account ID of the player
cardsArray.<Object>Player cards of this player in the bot's inventory
cards[].idnumberID of the card
cards[].bonusesArray.<Object>Array of bonuses that apply to this card
cards[].bonuses[].typeFantasyStatsThe stat that gets a bonus
cards[].bonuses[].valuenumberPercentage bonus for the stat
statsCMsgGCToClientPlayerStatsResponsePlayer stats

dota2Client.requestPlayerCardRoster(league_id, timestamp, callback)

Sends a message to the Game Coordinator requesting your fantasy line-up for a specific day of a given tournament. Provide a callback or listen for the playerCardRoster event for the Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
league_idnumberID of the league
timestampnumberDate in timeframe of the league
callbackrequestCallbackCalled with err, CMsgClientToGCGetPlayerCardRosterResponse

dota2Client.draftPlayerCard(league_id, timestamp, slot, player_card_id, callback)

Sends a message to the Game Coordinator requesting to draft a certain player card in a specific slot, for a given day in a tournament. Provide a callback or listen for the playerCardDrafted event for the Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
league_idnumberID of the league for which you're drafting a player card
timestampnumberTimestamp of the day for which you want to draft a player card
slotnumberSlot in the draft which you want to fill
player_card_idnumberItem ID of the player card you want to draft
callbackrequestCallbackCalled with err, CMsgClientToGCSetPlayerCardRosterResponse

dota2Client.setItemPositions(item_positions)

Attempts to change the position of one or more items in your inventory. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
item_positionsArray.<Object>The new positions of the items
item_positions[].item_idnumberID of the item
item_positions[].positionnumberNew position of the item

dota2Client.deleteItem(item_id)

Attempts to delete an item in your inventory. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
item_idnumberID of the item

dota2Client.requestTopLeagueMatches()

Sends a message to the Game Coordinator requesting the top league matches. Listen for the topLeagueMatchesData event for the Game Coordinator's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

dota2Client.createPracticeLobby(options, callback)

Sends a message to the Game Coordinator requesting to create a lobby. This will automatically make the bot join the first slot on radiant team. Listen for practiceLobbyUpdate response for a snapshot-update of the newly created lobby. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
optionsOptionsConfiguration options for the lobby
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.configPracticeLobby(lobby_id, options, callback)

Sends a message to the Game Coordinator requesting to configure some options of the active lobby. Listen for practiceLobbyUpdate response for a snapshot-update of the newly created lobby. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
lobby_idLongID of the lobby
optionsOptionsThe new option values
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.requestPracticeLobbyList(callback)

Requests a lists of joinable practice lobbies. Provide a callback or listen for the practiceLobbyListData event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgPracticeLobbyListResponse

dota2Client.requestFriendPracticeLobbyList(callback)

Requests a lists of joinable practice lobbies which have one of your friends in them. Provide a callback or listen for the friendPracticeLobbyListData event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgFriendPracticeLobbyListResponse

dota2Client.balancedShuffleLobby(callback)

Shuffles the lobby based on skill level. Requires you to be in a lobby and to be the host. Provide a callback or listen for the practiceLobbyResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.flipLobbyTeams(callback)

Flips the radiant and dire team players. Requires you to be in a lobby and to be the host. Provide a callback or listen for the practiceLobbyResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.inviteToLobby(steam_id)

Asks to invite a player to your lobby. This creates a new default lobby when you are not already in one. Listen for the inviteCreated event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
steam_idLongThe Steam ID of the player you want to invite.

dota2Client.practiceLobbyKick(account_id, callback)

Asks to kick someone from your current practice lobby. Requires you to be in a lobby and to be the host. Provide a callback or listen for the practiceLobbyResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberThe Dota2 account ID of the player you want to kick.
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.practiceLobbyKickFromTeam(account_id, callback)

Asks to kick someone from his chosen team in your current practice lobby. The player will be added to the player pool Provide a callback or listen for the practiceLobbyResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
account_idnumberThe Dota2 account ID of the player you want to kick from his team.
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.joinPracticeLobby(id, password, callback)

Sends a message to the Game Coordinator requesting to join a lobby. Provide a callback or listen for the practiceLobbyJoinResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
idexternalLongThe ID of the lobby
passwordnumberThe password of the lobby
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.leavePracticeLobby(callback)

Sends a message to the Game Coordinator requesting to leave the current lobby. Provide a callback or listen for the practiceLobbyResponse event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgPracticeLobbyJoinResponse

dota2Client.destroyLobby(callback)

Destroy the current lobby. Requires you to be the host. Provide a callback or listen for the lobbyDestroyed event for the GC's response. Requires the GC to be ready.

Kind: instance method of Dota2Client

ParamTypeDescription
callbackrequestCallbackCalled with err, CMsgDOTADestroyLobbyResponse

dota2Client.abandonCurrentGame(callback)

Abandons the current game. Provide a call

7.0.3

5 years ago

7.0.2

5 years ago

7.0.1

5 years ago

7.0.0

5 years ago

6.2.0

6 years ago

6.1.1

6 years ago

6.1.0

6 years ago

6.0.1

6 years ago

6.0.0

6 years ago

5.1.0

7 years ago

5.0.1

7 years ago

5.0.0

7 years ago

4.2.1

7 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

9 years ago

0.7.2

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.6

10 years ago

0.4.5

10 years ago

0.4.4

10 years ago

0.4.3

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.3.0

10 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago