Skip to content
This repository was archived by the owner on Jun 11, 2022. It is now read-only.

Commit a84f437

Browse files
authored
Merge pull request #361 from Arcana/dev
Bump to 4.1.0
2 parents bea2b55 + ffb0ad8 commit a84f437

24 files changed

+593
-160
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
3-
- "6.2.1"
4-
- "4.4.5"
3+
- "6.7.0"
4+
- "4.6.0"

README.md

+100-24
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ node-dota2
22
========
33

44
[![NPM version](https://img.shields.io/npm/v/dota2.svg)](https://npmjs.org/package/dota2 "View this project on NPM")
5-
[![Build Status](https://img.shields.io/travis/RJacksonm1/node-dota2.svg)](https://travis-ci.org/RJacksonm1/node-dota2 "View this project's build information")
6-
[![Dependency Status](https://img.shields.io/david/RJacksonm1/node-dota2.svg)](https://david-dm.org/RJacksonm1/node-dota2 "Check this project's dependencies")
5+
[![Build Status](https://img.shields.io/travis/Arcana/node-dota2.svg)](https://travis-ci.org/Arcana/node-dota2 "View this project's build information")
6+
[![Dependency Status](https://img.shields.io/david/Arcana/node-dota2.svg)](https://david-dm.org/Arcana/node-dota2 "Check this project's dependencies")
77

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

10-
Check out my blog post (my only blog post), [Extending node-dota2](https://blog.rjackson.me/extending-node-dota2/), for a rough overview of adding new functionality to the library.
10+
Check out RJackson1's blog post (his only blog post), [Extending node-dota2](https://blog.rjackson.me/extending-node-dota2/), for a rough overview of adding new functionality to the library.
1111
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.
1212
It is now easier to implement new functionality than it was back when this blog was written.
1313

1414
## Upgrade guide
1515

16-
### `3.*.*` to `4.0.0`
16+
### `3.*.*` to `4.*.0`
1717

1818
A few backwards incompatible API changes were included with version 4.0.0.
1919

@@ -46,6 +46,13 @@ var Steam = require('steam'),
4646
Dota2 = new dota2.Dota2Client(steamClient, true, false);
4747
```
4848

49+
## Disclaimer
50+
We do not in any way encourage people to use their own accounts when using this library.
51+
This library tries to mimic the behavior of the Dota 2 client to allow people to programmatically interact with the Dota 2 GC,
52+
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.
53+
While Valve has not yet expressed a dislike regarding reverse engineering projects like this one,
54+
it's not unimaginable that this might one day change and result in VAC bans.
55+
4956
## Examples
5057
The `examples` directory contains two Dota2 bots as an example. One contains commented-out dota2 methods, the other has boolean activated methods.
5158
Both examples show how to interact with the library.
@@ -106,9 +113,9 @@ Attempts to delete an item. Requires the GC to be ready (listen for the `ready`
106113
### Chat
107114
**_Limited Steam accounts cannot interact with chat!_**
108115

109-
#### joinChat(channel, [type])
110-
* `channel` - A string for the channel name.
111-
* `[type]` - The type of the channel being joined. Defaults to `Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Custom`.
116+
#### joinChat(channel_name, [channel_type])
117+
* `channel_name` - A string for the channel name.
118+
* `[channel_type]` - The type of the channel being joined. Defaults to `Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Custom`.
112119

113120
Joins a chat channel. If the chat channel with the given name doesn't exist, it
114121
is created. Listen for the `chatMessage` event for other people's chat messages.
@@ -117,28 +124,35 @@ Notable channels:
117124
* `Guild_##########` - The chat channel of the guild with guild_id = ##########
118125
* `Lobby_##########` - The chat channel of the lobby with lobby_id = ##########
119126

120-
#### leaveChat(channel)
121-
* `channel` - A string for the channel name.
127+
#### leaveChat(channel_name, [channel_type])
128+
* `channel_name` - A string for the channel name.
129+
* `[channel_type]` - The type of the channel you want to leave. Use the `Dota2.schema.DOTAChatChannelType_t` enum.
122130

123-
Leaves a chat channel.
131+
Leaves a chat channel. If you've joined different channels with the same name, specify the type to prevent unexpected behaviour.
124132

125-
#### sendMessage(channel, message)
133+
#### sendMessage(channel, message, [channel_type])
126134
* `channel` - A string for the channel name.
127135
* `message` - The message you want to send.
136+
* `[channel_type]` - The type of the channel you want to send a message to. Use the `Dota2.schema.DOTAChatChannelType_t` enum.
128137

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

131-
#### flipCoin(channel)
141+
#### flipCoin(channel, [channel_type])
132142
* `channel` - A string for the channel name.
143+
* `[channel_type]` - The type of the channel you want to flip a coin in. Use the `Dota2.schema.DOTAChatChannelType_t` enum.
133144

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

136-
#### rollDice(channel, min, max)
148+
#### rollDice(channel, min, max, [channel_type])
137149
* `channel` - A string for the channel name.
138150
* `min` - Lower bound of the dice roll.
139151
* `max` - Upper bound of the dice roll.
152+
* `[channel_type]` - The type of the channel you want to roll a dice in. Use the `Dota2.schema.DOTAChatChannelType_t` enum.
140153

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

143157
#### requestChatChannels()
144158

@@ -222,6 +236,8 @@ Requests the list of pro teams.
222236
* `[matches_requested]` - How many matches to retrieve
223237
* `[hero_id]` - The ID of the hero the given account ID had played
224238
* `[request_id]` - I have no idea.
239+
* `[include_practice_matches]` - Do you want practice matches in the result sets?
240+
* `[include_custom_games]` - Do you want custom games in the result sets?
225241
* `[callback]` - optional callback, returns args: `err, response`.
226242

227243
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.
@@ -267,6 +283,13 @@ Sends a message to the Game Coordinator requesting one or multiple `account_ids`
267283

268284
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 (listen for the `ready` event before calling). Notably, this data contains the `profile_name` field, which is the user's name displayed on their profile page in dota.
269285

286+
#### requestPlayerStats(account_id, [callback])
287+
* `account_id` - Account ID (lower 32-bits of a 64-bit Steam ID) of the user whose player stats you wish to view.
288+
* `[callback]` - optional callback, returns args: `err, response`.
289+
*
290+
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. Requires the GC to be ready (listen for the `ready` event before calling). This data contains all stats shown on a player's profile page.
291+
292+
270293
### Matches
271294
#### requestMatches(criteria, [callback])
272295
* `[criteria]` - The options available for searching matches:
@@ -311,9 +334,10 @@ Sends a message to the Game Coordinator requesting the top matches of your frien
311334

312335
### Parties
313336

314-
### respondPartyInvite(id, accept)
315-
* `[id]` - Number, party ID.
316-
* `[accept]` - Accept or decline the invite.
337+
### respondPartyInvite(id, accept, [ping_data])
338+
* `id` - Number, party ID.
339+
* `accept` - Accept or decline the invite.
340+
* `[ping_data]` - Optional argument to be provided when accepting a party invite. For contents see `CMsgClientPingData`.
317341

318342
Responds to an incoming party invite. The `PartyInvite` property is cleared after the response has been sent.
319343

@@ -336,6 +360,12 @@ Kicks a player from the party. This will create a new party if you aren't in one
336360
Set the bot's status as a coach.
337361

338362

363+
### setPartyLeader(id)
364+
* `[id]` - The steam ID of new party leader.
365+
366+
Set the new party leader.
367+
368+
339369
### leaveParty()
340370

341371
Leaves the current party. See the `Party` property.
@@ -511,6 +541,11 @@ Emitted when the GC is ready to receive messages. Be careful not to declare ano
511541
### `unready`
512542
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.
513543

544+
### `popup` (`type`, `popup`)
545+
* `type` - The type of the popup. See `CMsgDOTAPopup.PopupID`
546+
* `popup` - The raw popup data
547+
548+
Generic popup, can be produced for a plethora of reasons.
514549

515550
### `chatMessage` (`channel`, `senderName`, `message`, `chatObject`)
516551
* `channel` - Channel name.
@@ -680,6 +715,31 @@ Emitted when GC responds to the `requestPassportData` method.
680715

681716
See the [protobuf schema](https://github.com/SteamRE/SteamKit/blob/master/Resources/Protobufs/dota/dota_gcmessages_client_fantasy.proto#L961) for `passportData`'s object structure.
682717

718+
### `playerStatsData` (`account_id`, `playerStats`)
719+
* `account_id` - Account ID whom the stats belong to.
720+
* `playerStats` - Statistics about the player. This entails:
721+
* `account_id`
722+
* `player_stats`
723+
* `match_count`
724+
* `mean_gpm`
725+
* `mean_xppm`
726+
* `mean_lasthits`
727+
* `rampages`
728+
* `triple_kills`
729+
* `first_blood_claimed`
730+
* `first_blood_given`
731+
* `couriers_killed`
732+
* `aegises_snatched`
733+
* `cheeses_eaten`
734+
* `creeps_stacked`
735+
* `fight_score`
736+
* `farm_score`
737+
* `support_score`
738+
* `push_score`
739+
* `versatility_score`
740+
741+
Emitted when the GC responds to the `requestPlayerStats` method.
742+
683743
### `hallOfFameData` (`week`, `featuredPlayers`, `featuredFarmer`, `hallOfFameResponse`)
684744
* `week` - Week the data is associated with.
685745
* `featuredPlayers` - Array of featured players for that week. `[{ account_id, heroId, averageScaledMetric, numGames }]`
@@ -714,7 +774,7 @@ See the [protobuf schema](https://github.com/SteamRE/SteamKit/blob/5acc8bb72bb7f
714774
* `matchmakingStatsResponse` - Raw response object.
715775

716776
Emitted when te GC response to the `requestMatchmakingStats` method. The array order dictates which matchmaking groups the figure belongs to.
717-
The groups are discoverable through `regions.txt` in Dota 2's game files. We maintain an indicative list *without guarantees* in this README.
777+
The groups are discoverable through [regions.txt](https://github.com/SteamDatabase/GameTracking/blob/master/dota/game/dota/pak01_dir/scripts/regions.txt) in Dota 2's game files. We maintain an indicative list *without guarantees* in this README.
718778
This list is manually updated only when changes are detected by community members, so it can be out of date.
719779
Here are the groups at the time of this sentence being written (with unecessary data trimmed out):
720780

@@ -738,7 +798,8 @@ Here are the groups at the time of this sentence being written (with unecessary
738798
"India": {"matchgroup": "16"},
739799
"PerfectWorldTelecomGuangdong": {"matchgroup": "17"},
740800
"PerfectWorldTelecomZhejiang": {"matchgroup": "18"},
741-
"Japan": {"matchgroup": "19"}
801+
"Japan": {"matchgroup": "19"},
802+
"PerfectWorldTelecomWuhan": {"matchgroup": "20"}
742803
```
743804

744805
### `topFriendMatchesData` (`matches`)
@@ -755,7 +816,7 @@ Emitted when the GC responds to the `requestTopFriendMatches` method.
755816

756817

757818
### `practiceLobbyUpdate` (`lobby`)
758-
* `lobby` - The full lobby object (see CSODOTALobby).
819+
* `lobby` - The full lobby object (see `CSODOTALobby`).
759820

760821

761822
Emitted when the GC sends a lobby snapshot. The GC is incredibly
@@ -815,7 +876,7 @@ Emitted when the GC has created the invitation. The invitation is only sent when
815876
the invitee is online.
816877

817878
### `partyUpdate` (`party`)
818-
* `party` - The full party object (see CSODOTAParty).
879+
* `party` - The full party object (see `CSODOTAParty`).
819880

820881

821882
Emitted when the GC sends a party snapshot. The GC is incredibly
@@ -919,13 +980,21 @@ Emitted when the GC responds to the `requestSourceTVGames` method. Multiple eve
919980
* `EUROPE: 3`
920981
* `KOREA: 4`
921982
* `SINGAPORE: 5`
983+
* `DUBAI: 6`
922984
* `AUSTRALIA: 7`
923985
* `STOCKHOLM: 8`
924986
* `AUSTRIA: 9`
925987
* `BRAZIL: 10`
926988
* `SOUTHAFRICA: 11`
927-
* `PERFECTWORLDTELECOM: 12`
928-
* `PERFECTWORLDUNICOM: 13`
989+
* `PWTELECOMSHANGHAI: 12`
990+
* `PWUNICOM: 13`
991+
* `CHILE: 14`
992+
* `PERU: 15`
993+
* `INDIA: 16`
994+
* `PWTELECOMGUANGZHOU: 17`
995+
* `PWTELECOMZHEJIANG: 18`
996+
* `JAPAN: 19`
997+
* `PWTELECOMWUHAN: 20`
929998

930999
Use this to pass valid server region data to `createPracticeLobby`.
9311000

@@ -946,8 +1015,15 @@ Use this to pass valid server region data to `createPracticeLobby`.
9461015
* `DOTA_GAMEMODE_POOL1: 13` - Limited Heroes
9471016
* `DOTA_GAMEMODE_FH: 14` - Compendium
9481017
* `DOTA_GAMEMODE_CUSTOM: 15` - Unknown, probably ti4 techies reveal.
949-
950-
Use this to pass valid game mode data to `createPracticeLobby`.
1018+
* `DOTA_GAMEMODE_CD: 16` - Captain's Draft
1019+
* `DOTA_GAMEMODE_BD: 17` - Balanced Draft
1020+
* `DOTA_GAMEMODE_ABILITY_DRAFT: 18` - Ability Draft
1021+
* `DOTA_GAMEMODE_EVENT: 19` - Unknown
1022+
* `DOTA_GAMEMODE_ARDM: 20` - All Random Death Match
1023+
* `DOTA_GAMEMODE_1V1MID: 21` - 1v1 Mid
1024+
* `DOTA_GAMEMODE_ALL_DRAFT: 22` - All Draft a.k.a. ranked all pick
1025+
1026+
Use this to pass valid game mode data to `createPracticeLobby`. This enum is built-in the protobuf schema and can be referenced by `Dota2.DOTA_GameMode`.
9511027

9521028

9531029

handlers/chat.js

+25-22
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ var Dota2 = require("../index"),
22
util = require("util");
33

44
// Methods
5-
Dota2.Dota2Client.prototype._getChannelByName = function(channel_name) {
5+
Dota2.Dota2Client.prototype._getChannelByName = function(channel_name, channel_type) {
66
// Returns the channel corresponding to the given channel_name
77
if (this.chatChannels) {
88
return this.chatChannels.filter(
99
function(item) {
10-
return (item.channel_name === channel_name);
10+
if(channel_type >= 0)
11+
return (item.channel_name === channel_name && item.channel_type === channel_type);
12+
else
13+
return (item.channel_name === channel_name);
1114
}
1215
)[0];
1316
} else {
@@ -29,24 +32,24 @@ Dota2.Dota2Client.prototype._getChannelById = function(channel_id) {
2932
}
3033
}
3134

32-
Dota2.Dota2Client.prototype.joinChat = function(channel, type) {
33-
type = type || Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Custom;
35+
Dota2.Dota2Client.prototype.joinChat = function(channel_name, channel_type) {
36+
channel_type = channel_type || Dota2.schema.DOTAChatChannelType_t.DOTAChannelType_Custom;
3437

3538
/* Attempts to join a chat channel. Expect k_EMsgGCJoinChatChannelResponse from GC */
36-
if (this.debug) util.log("Joining chat channel: " + channel);
39+
if (this.debug) util.log("Joining chat channel: " + channel_name);
3740

3841
var payload = new Dota2.schema.CMsgDOTAJoinChatChannel({
39-
"channel_name": channel,
40-
"channel_type": type
42+
"channel_name": channel_name,
43+
"channel_type": channel_type
4144
});
4245
this.sendToGC(Dota2.schema.EDOTAGCMsg.k_EMsgGCJoinChatChannel, payload);
4346
};
4447

45-
Dota2.Dota2Client.prototype.leaveChat = function(channel) {
48+
Dota2.Dota2Client.prototype.leaveChat = function(channel_name, channel_type) {
4649
/* Attempts to leave a chat channel. GC does not send a response. */
47-
if (this.debug) util.log("Leaving chat channel: " + channel);
50+
if (this.debug) util.log("Leaving chat channel: " + channel_name);
4851
// Clear cache
49-
var cache = this._getChannelByName(channel);
52+
var cache = this._getChannelByName(channel_name, channel_type);
5053
if (cache === undefined) {
5154
if (this.debug) util.log("Cannot leave a channel you have not joined.");
5255
return;
@@ -58,11 +61,11 @@ Dota2.Dota2Client.prototype.leaveChat = function(channel) {
5861
this.sendToGC(Dota2.schema.EDOTAGCMsg.k_EMsgGCLeaveChatChannel, payload);
5962
};
6063

61-
Dota2.Dota2Client.prototype.sendMessage = function(channel, message) {
64+
Dota2.Dota2Client.prototype.sendMessage = function(channel_name, message, channel_type) {
6265
/* Attempts to send a message to a chat channel. GC does not send a response. */
63-
if (this.debug) util.log("Sending message to " + channel);
66+
if (this.debug) util.log("Sending message to " + channel_name);
6467
// Check cache
65-
var cache = this._getChannelByName(channel);
68+
var cache = this._getChannelByName(channel_name, channel_type);
6669
if (cache === undefined) {
6770
if (this.debug) util.log("Cannot send message to a channel you have not joined.");
6871
return;
@@ -75,11 +78,11 @@ Dota2.Dota2Client.prototype.sendMessage = function(channel, message) {
7578
this.sendToGC(Dota2.schema.EDOTAGCMsg.k_EMsgGCChatMessage, payload);
7679
};
7780

78-
Dota2.Dota2Client.prototype.shareLobby = function(channel) {
81+
Dota2.Dota2Client.prototype.shareLobby = function(channel_name, channel_type) {
7982
/* Attempts to send a message to a chat channel. GC does not send a response. */
80-
if (this.debug) util.log("Sharing lobby to " + channel);
83+
if (this.debug) util.log("Sharing lobby to " + channel_name);
8184
// Check cache
82-
var cache = this._getChannelByName(channel);
85+
var cache = this._getChannelByName(channel_name, channel_type);
8386
if (cache === undefined) {
8487
if (this.debug) util.log("Cannot send message to a channel you have not joined.");
8588
return;
@@ -97,11 +100,11 @@ Dota2.Dota2Client.prototype.shareLobby = function(channel) {
97100
this.sendToGC(Dota2.schema.EDOTAGCMsg.k_EMsgGCChatMessage, payload);
98101
};
99102

100-
Dota2.Dota2Client.prototype.flipCoin = function(channel) {
103+
Dota2.Dota2Client.prototype.flipCoin = function(channel_name, channel_type) {
101104
/* Attempts to send a coin flip to a chat channel. Expect a chatmessage in response. */
102-
if (this.debug) util.log("Sending coin flip to " + channel);
105+
if (this.debug) util.log("Sending coin flip to " + channel_name);
103106
// Check cache
104-
var cache = this._getChannelByName(channel);
107+
var cache = this._getChannelByName(channel_name, channel_type);
105108
if (cache === undefined) {
106109
if (this.debug) util.log("Cannot send message to a channel you have not joined.");
107110
return;
@@ -114,11 +117,11 @@ Dota2.Dota2Client.prototype.flipCoin = function(channel) {
114117
this.sendToGC(Dota2.schema.EDOTAGCMsg.k_EMsgGCChatMessage, payload);
115118
};
116119

117-
Dota2.Dota2Client.prototype.rollDice = function(channel, min, max) {
120+
Dota2.Dota2Client.prototype.rollDice = function(channel_name, min, max, channel_type) {
118121
/* Attempts to send a dice roll to a chat channel. Expect a chatmessage in response. */
119-
if (this.debug) util.log("Sending dice roll to " + channel);
122+
if (this.debug) util.log("Sending dice roll to " + channel_name);
120123
// Check cache
121-
var cache = this._getChannelByName(channel);
124+
var cache = this._getChannelByName(channel_name, channel_type);
122125
if (cache === undefined) {
123126
if (this.debug) util.log("Cannot send message to a channel you have not joined.");
124127
return;

0 commit comments

Comments
 (0)