A node-steam plugin for Dota 2, consider it in alpha state.
Check out my blog post (my only blog post), Extending node-dota2, for a rough overview of adding new functionality to the library.
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.
var Steam = require('steam'),
steamClient = new Steam.SteamClient(),
dota2 = require('dota2'),
Dota2 = new dota2.Dota2Client(steamClient, true);
##Properties
###AccountID
The current steam ID of the SteamClient converted to Dota 2 Account ID format. Not available until launch
is called.
###Lobby The current lobby object (see CSODOTALobby). Null if the bot is not in a lobby.
###Party The current party object (see CSODOTAParty). Null if the bot is not in a party.
###PartyInvite The current party invite object (see CSODOTAPartyInvite). Null if the bot does not have an active incoming party invite.
All methods require the SteamClient instance to be logged on.
Reports to Steam that you're playing Dota 2, and then initiates communication with the Game Coordinator.
Tells Steam you were feeding.
###Utilities
- Takes an input steam ID in any format and converts it into an int Account ID.
- Takes an input Dota 2 acount ID in any format and converts it into a string steam ID.
itemPositions
- An array of tuples (itemid, position).
Attempts to move items within your inventory to the positions you set. Requires the GC to be ready (listen for the ready
event before calling).
Attempts to delete an item. Requires the GC to be ready (listen for the ready
event before calling).
channel
- A string for the channel name.[type]
- The type of the channel being joined. Defaults todota2.DOTAChatChannelType_t.DOTAChannelType_Custom
.
Joins a chat channel. Listen for the chatMessage
event for other people's chat messages.
channel
- A string for the channel name.
Leaves a chat channel.
channel
- A string for the channel name.message
- The message you want to send.
Sends a message to the specified chat channel, won't send if you're not in the channel you try to send to.
Sends a request to the GC for new guild data, which returns openPartyData
events - telling the client the status of current open parties for each guild, as well as exposing guildIds
to the client.
guildId
- ID of a guild.targetAccountId
- Account ID (lower 32-bits of a 64-bit steam id) of user to invite to guild.[callback]
- optional callback, returns args:err, response
.
Attempts to invite a user to guild. Requires the GC to be ready (listen for the ready
event before calling).
guildId
- ID of a guild.targetAccountId
- Account ID (lower 32-bits of a 64-bit steam id) of user whoms guild invite you wish to cancel.[callback]
- optional callback, returns args:err, response
.
Attempts to cancel a user's guild invitation; use this on your own account ID to reject guild invitations. Requires the GC to be ready (listen for the ready
event before calling).
guildId
- ID of a guild.targetAccountId
- Account ID (lower 32-bits of a 64-bit steam id) of user whoms guild invite you wish to cancel.targetRole
- Role in guild to have.-
0
- Kick member from guild.
-
1
- Leader.
-
2
- Officer.
-
3
- Member.
[callback]
- optional callback, returns args:err, response
.
Attempts to set a user's role within a guild; use this with your own account ID and the 'Member' role to accept guild invitations. Requires the GC to be ready (listen for the ready
event before calling).
accountId
- Account ID (lower 32-bits of a 64-bit Steam ID) of the user whose passport data you wish to view.requestName
- Boolean, whether you want the GC to return the accounts current display name.[callback]
- optional callback, returns args:err, response
.
Sends a message to the Game Coordinator requesting accountId
's profile data. Provide a callback or listen for profileData
event for Game Coordinator's response. Requires the GC to be ready (listen for the ready
event before calling).
accountId
- Account ID (lower 32-bits of a 64-bit Steam ID) of the user whose passport data you wish to view.[callback]
- optional callback, returns args:err, response
.
Sends a message to the Game Coordinator requesting accountId
's passport data. Provide a callback or listen for passportData
event for Game Coordinator's response. Requires the GC to be ready (listen for the ready
event before calling).
[week]
- The week of which you wish to know the Hall of Fame members; will return latest week if omitted. Weeks also randomly start at 2233 for some reason, valf please.[callback]
- optional callback, returns args:err, response
.
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 (listen for the ready
event before calling).
matchId
- The matches ID[callback]
- optional callback, returns args:err, response
.
Sends a message to the Game Coordinator requesting matchId
's match details. Provide a callback or listen for matchData
event for Game Coordinator's response. Requires the GC to be ready (listen for the ready
event before calling).
Note: There is a server-side rate-limit of 100 requests per 24 hours on this method.
Sends a message to the Game Coordinator requesting some matchmaking stats. Listen for the matchmakingStatsData
event for the Game Coordinator's response (cannot take a callback because of Steam's backend, or RJackson's incompetence; not sure which). Requires the GC to be ready (listen for the ready
event before calling).
[id]
Number, party ID.[accept]
Accept or decline the invite.
Responds to an incoming party invite. See the PartyInvite
property.
[id]
The steam ID to invite.
Invites a player to a party. This will create a new party if you aren't in one.
[id]
The steam ID to kick.
Kicks a player from the party. This will create a new party if you aren't in one.
[coach]
Boolean, if the bot wants to be coach or not.
Set the bot's status as a coach.
Leaves the current party. See the Party
property.
[id]
Practice lobby ID[password]
Practice lobby password
Sends a message to the Game Coordinator requesting to join a lobby. Provide a callback or listen for practiceLobbyJoinResponse
for the Game Coordinator's response. Requires the GC to be ready (listen for the ready
event before calling).
[gameName]
Display name for the lobby (optional).[password]
Password to restrict access to the lobby (optional).[serverRegion]
Server region for the lobby` see ServerRegion Enum (optional).[gameMode]
Gamemode for the lobby` see GameMode Enum(optional).
Sends a message to the Game Coordinator requesting to create a lobby. Listen for practiceLobbyUpdate
response for a snapshot-update of the newly created lobby. Requires the GC to be ready (listen for the ready
event before calling).
Shuffles the lobby teams.
Flips the teams in a lobby.
id
Lobby IDoptions
A set of options to set. All are optional, but send at least one.-
game_name
: String, lobby title.
-
server_region
: Use the server region enum.
-
game_mode
: Use the game mode enum.
-
allow_cheats
: True/false, allow cheats.
-
fill_with_bots
: Fill available slots with bots?
-
allow_spectating
: Allow spectating?
-
pass_key
: Password.
-
series_type
: Use the series type enum.
-
radiant_series_wins
: Best of 3 for example, # of games won so far.
-
dire_series_wins
: Best of 3 for example, # of games won so far.
-
allchat
: Enable all chat?
Sends a message to the Game Coordinator requesting to configure some options of the active lobby. Requires the GC to be ready (listen for the ready
event before calling).
Sends a message to the GC requesting the currrent lobby be started (server found and game begins). You will receive updates in the practiceLobbyUpdate
response.
accountid
The ID of the player you want to kick.
Asks to kick someone from your current practice lobby.
Sends a message to the Game Coordinator requesting to leave the current lobby. Requires the GC to be ready (listen for the ready
event before calling).
[month]
- Int for the month (MM) you want to query data for. Defaults to current month. IMPORTANT NOTE: Month is zero-aligned, not one-aligned; so Jan = 00, Feb = 01, etc.[year]
- Int for the year (YYYY) you want to query data for . Defaults to current year.[callback]
- optional callbackreturns args:
errresponse
.
Sends a message to the Game Coordinator requesting data on leagues being played in the given month. Provide a callback or listen for leaguesInMonthResponse
for the Game Coordinator's response. Requires the GC to be ready (listen for the ready
event before calling).
[filterOption]
- Object to override the default filters[callback]
- callback to be executed, return args:response
Returns a list of current ongoing matches (from live games tab).
Default filterOptions:
{
searchKey: '',
start: 0, // offset
numGames: 6,
leagueid: 0,
heroid: 0,
teamGame: false, // only show team games (team matchmaking)
customGameId: 0,
}
Important: The only working parameters are
start
,leagueid
andteamGame
. Changing the other parameters will result in no response at all (e.g.numGames
> 6)
Emitted when the GC is ready to receive messages. Be careful not to declare anonymous functions as event handlers here, as you'll need to be able to invalidate event handlers on an unready
event.
Emitted when the connection status to the GC changes, and renders the library unavailable to interact. You should clear any event handlers set in the ready
event here, otherwise you'll have multiple handlers for each message every time a new ready
event is sent.
channel
- Channel name.senderName
- Persona name of user who sent message.message
- Wot u think?chatObject
- The raw chat object to do with as you wish.
Emitted for chat messages received from Dota 2 chat channels
guildId
- ID of the guild.openParties
- Array containing information about open guild parties. Each object has the following properties:-
partyId
- Unique ID of the party.
-
member_account_ids
- Array of account ids.
-
time_created
- Something about Back to the Future.
-
description
- A user-inputted string. Do not trust.
Emitted for each guild the bot's account is a member of, containing information on open parties for each guild. Also exposes guildId's, which is handy.
guildId
- ID of the guild.guildName
- Name of the guild.inviter
- Account ID of user whom invited you.guildInviteDataObject
- The raw guildInviteData object to do with as you wish.
You can respond with cancelInviteToGuild
or setGuildAccountRole
.
accountId
- Account ID whom the data is associated with.profileData
- The raw profile data object.
Emitted when GC responds to the profileRequest
method.
See the protobuf schema for profileData
's object structure.
accountId
- Account ID whom the passport belongs to.passportData
- The raw passport data object.
Emitted when GC responds to the passportDataRequest
method.
See the protobuf schema for passportData
's object structure.
matchId
- Match ID whom the data is associatd with.matchData
- The raw match details data object.
Emitted when GC responds to the matchDetailsRequest
method.
See the protobuf schema for matchData
's object structure.
week
- Week the data is associated with.featuredPlayers
- Array of featured players for that week.[{ accountId, heroId, averageScaledMetric, numGames }]
featuredFarmer
- Featured farmer for that week.{ accountId, heroId, goldPerMin, matchId }
hallOfFameResponse
- Raw response object.
Emitted when the GC responds to the hallOfFameRequest
method.
matchmakingStatsData
(waitTimesByGroup
, searchingPlayersByGroup
, disabledGroups
, matchmakingStatsResponse
)
waitTimesByGroup
- Current average matchmaking waiting times, in seconds, per group.searchingPlayersByGroup
- Current players searching for matches per group.disabledGroups
- I don't know how the data is formatted here, I've only observed it to be zero.matchmakingStatsResponse
- Raw response object.
Emitted when te GC response to the matchmakingStatsRequest
method. The array order dictates which matchmaking groups the figure belongs to, the groups are discoverable through regions.txt
in Dota 2's game files. Here are the groups at the time of this sentence being written (with unecessary data trimmed out):
"USWest": {"matchgroup": "0"},
"USEast": {"matchgroup": "1"},
"Europe": {"matchgroup": "2"},
"Singapore": {"matchgroup": "3"},
"Shanghai": {"matchgroup": "4"},
"Brazil": {"matchgroup": "5"},
"Korea": {"matchgroup": "6"},
"Austria": {"matchgroup": "8"},
"Stockholm": {"matchgroup": "7"},
"Australia": {"matchgroup": "9"},
"SouthAfrica": {"matchgroup": "10"},
"PerfectWorldTelecom": {"matchgroup": "11"},
"PerfectWorldUnicom": {"matchgroup": "12"}
lobby
- The full lobby object (see CSODOTALobby).
Emitted when the GC sends a lobby snapshot. The GC is incredibly
inefficient and will send the entire object even if it's a minor update.
You can use this to detect when a lobby has been entered / created
successfully as well. Note that the Lobby
property will be the old
value until after this event completes to allow comparison between the
two.
result
- The result object frompracticeLobbyJoinResponse
.practiceLobbyJoinResponse
- The raw response object.
Emitted when the GC responds to joinPracticeLobby
method.
Emitted when leaving a lobby (aka, the lobby is cleared). This can happen when kicked, upon leaving a lobby, etc. There are other callbacks to tell when the bot has been kicked.
party
- The full party object (see CSODOTAParty).
Emitted when the GC sends a party snapshot. The GC is incredibly
inefficient and will send the entire object even if it's a minor update.
You can use this to detect when a party has been entered / created
successfully as well. Note that the Party
property will be the old
value until after this event completes to allow comparison between the
two.
Emitted when leaving a party (aka, the party is cleared). This can happen when kicked, upon leaving a party, etc. There are other callbacks to tell when the bot has been kicked.
partyInvite
- The full party invite object (see CSODOTAPartyInvite).
Emitted when the GC sends a party invite snapshot. The GC is incredibly
inefficient and will send the entire object even if it's a minor update.
You can use this to detect when an incoming party invite has been sent.
Note that the PartyInvite
property will be the old
value until after this event completes to allow comparison between the two.
Emitted when the Party Invite is cleared, for example when accepting/rejecting it or when the party is closed.
null
- nothingliveLeaguesResponse
- Integer representing number of live league games.
result
- The result object fromleaguesInMonthResponse
.leaguesInMonthResponse
- The raw response object.
Emitted when the GC responds to leaguesInMonthRequest
method.
Notes:
- The
month
property is used to filter the data to the leagues which have matches scheduled in the given month, however theschedule
object contains schedules for a league's entire duration - i.e. before or aftermonth
. month
is also zero-aligned, so January = 0, Febuary = 1, March = 2, etc.- Not every participating team seems to be hooked up to Dota 2's team system, so there will be a few
{ teamId: 0 }
objects for some schedule blocks.
The response object is visualized as follows:
{
eresult, // EResult enum
month, // Int representing which month this data represents.
leagues: [{ // An array of CMsgLeague objects
leagueId, // ID of the league associated
schedule: [{ // An array of CMsgLeagueScheduleBlock objects
blockId, // ID represending this block
startTime, // Unix timestamp of a scheduled match (or group of matches)
finals, // Boolean represending if this match is a final.
comment, // Comment about this scheduled block - often the team names & position in bracket
teams: [{ // An array of CMsgLeagueScheduleBlockTeamInfo objects
teamId, // ID of the associated team
name, // The teams name
tag, // The teams tag
logo // The teams logo
}]
}]
}]
}
UNSPECIFIED: 0
USWEST: 1
USEAST: 2
EUROPE: 3
KOREA: 4
SINGAPORE: 5
AUSTRALIA: 7
STOCKHOLM: 8
AUSTRIA: 9
BRAZIL: 10
SOUTHAFRICA: 11
PERFECTWORLDTELECOM: 12
PERFECTWORLDUNICOM: 13
Use this to pass valid server region data to createPracticeLobby
.
DOTA_GAMEMODE_NONE: 0
- NoneDOTA_GAMEMODE_AP: 1
- All PickDOTA_GAMEMODE_CM: 2
- Captain's ModeDOTA_GAMEMODE_RD: 3
- Random DraftDOTA_GAMEMODE_SD: 4
- Single DraftDOTA_GAMEMODE_AR: 5
- All RandomDOTA_GAMEMODE_INTRO: 6
- UnknownDOTA_GAMEMODE_HW: 7
- DiretideDOTA_GAMEMODE_REVERSE_CM: 8
- Reverse Captain's ModeDOTA_GAMEMODE_XMAS: 9
- The GreevilingDOTA_GAMEMODE_TUTORIAL: 10
- TutorialDOTA_GAMEMODE_MO: 11
- Mid OnlyDOTA_GAMEMODE_LP: 12
- Least PlayedDOTA_GAMEMODE_POOL1: 13
- Limited HeroesDOTA_GAMEMODE_FH: 14
- CompendiumDOTA_GAMEMODE_CUSTOM: 15
- Unknown, probably ti4 techies reveal.
Use this to pass valid game mode data to createPracticeLobby
.
There is no automated test suite for node-dota2 (I've no idea how I'd make one for the stuff this does :o), however there the test
directory does contain a Steam bot with commented-out dota2 methods; you can use this bot to test the library.
npm install
in the repository root.npm install
in thetest
directory.- Copy
config_SAMPLE.js
toconfig.js
and edit appropriately. - Create a blank file named 'sentry' in the tests directory.
- Attempt to log-in, you'll receive Error 63 - which means you need to provide a Steam Guard code.
- Set the Steam Guard code in
config.js
and launch again.