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

Commit 8b018c4

Browse files
authored
Merge pull request #556 from Arcana/dev
6.0.0 Merge
2 parents 0354661 + 254e40b commit 8b018c4

22 files changed

+342
-221
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-
- "8.1.2"
4-
- "6.11.0"
3+
- "8.9.1"
4+
- "9.2.0"

CHANGELOG.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
# Changelog 6.0.0
2+
## General
3+
Fixed some chat channel bugs
4+
5+
## API changes
6+
### Methods
7+
#### requestLeaguesInMonth
8+
Proto message was removed so corresponding function also removed
9+
10+
#### destroyLobby
11+
New function for lobby host that destroys the lobby
12+
13+
### Events
14+
#### leaguesInMonthData
15+
Removed because Valve removed proto message
16+
117
# Changelog 5.2.0
218
## Dependency changes
319
Nothing new, just some updates
420

521
## API changes
6-
### methods
22+
### Methods
723
#### requestPlayerCardsByPlayer
824
Now parses the bonuses
925

README.md

+31-47
Large diffs are not rendered by default.

examples/example2.js

+20-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
4343

4444
// COMMUNITY
4545

46-
var accId = 63470426;
46+
var accId = 103637655;
4747
// var playerInfo = 0;
4848
var playerInfo2 = 0;
4949
// var playerInfo3 = 0;
@@ -106,8 +106,9 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
106106

107107
// LOBBY
108108

109-
var creatingLobby = 1;
110-
var leavingLobby = 1;
109+
var creatingLobby = 0;
110+
var leavingLobby = 0;
111+
var destroyLobby = 0;
111112
var lobbyChannel = "";
112113

113114
if(creatingLobby == 1){ // sets only password, nothing more
@@ -151,6 +152,18 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
151152
}, 10000);
152153
}
153154

155+
if(destroyLobby == 1){
156+
setTimeout(function(){
157+
Dota2.destroyLobby(function(err, data){
158+
if (err) {
159+
util.log(err + ' - ' + JSON.stringify(data));
160+
} else {
161+
if(lobbyChannel) Dota2.leaveChat(lobbyChannel);
162+
}
163+
});
164+
}, 10000);
165+
}
166+
154167
// ----------------------------------
155168

156169
// TEAM
@@ -186,8 +199,10 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
186199
Dota2.on("inventoryUpdate", inventory => {
187200
// Time-out so inventory property is updated
188201
setTimeout(()=>{
189-
Promise.all(Dota2.requestPlayerCardsByPlayer()).then(cards => console.log(cards));
190-
}, 1000);
202+
Promise.all(Dota2.requestPlayerCardsByPlayer()).then(cards => {
203+
fs.writeFileSync('cards.js',JSON.stringify(cards));
204+
});
205+
}, 10000);
191206
});
192207
}
193208
});

handlers/chat.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@ handlers[Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgGCJoinChatChannelRes
264264
var onChatMessage = function onChatMessage(message) {
265265
/* Chat channel message from another user. */
266266
var chatData = Dota2.schema.lookupType("CMsgDOTAChatMessage").decode(message);
267-
var channel = this._getChannelById(chatData.channel_id);
267+
var channel = this._getChannelById(chatData.channel_id) || {
268+
channel_name: "Unknown"
269+
};
268270

269271
this.Logger.debug("Received chat message from " + chatData.persona_name + " in channel " + channel.channel_name);
270272
this.emit("chatMessage",
@@ -278,8 +280,11 @@ handlers[Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgGCChatMessage] = onC
278280
var onOtherJoinedChannel = function onOtherJoinedChannel(message) {
279281
/* Someone joined a chat channel you're in. */
280282
var otherJoined = Dota2.schema.lookupType("CMsgDOTAOtherJoinedChatChannel").decode(message);
281-
var channel = this._getChannelById(otherJoined.channel_id);
282-
this.Logger.debug(otherJoined.steam_id + " joined channel " + channel.channel_name);
283+
var channel = this._getChannelById(otherJoined.channel_id) || {
284+
channel_name: "Unknown",
285+
members: []
286+
};
287+
this.Logger.debug(otherJoined.steam_id + " joined channel " + channel.channel_name);
283288
this.emit("chatJoin",
284289
channel.channel_name,
285290
otherJoined.persona_name,

handlers/leagues.js

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

44
// Methods
5-
/**
6-
* Sends a message to the Game Coordinator requesting data on leagues being played in the given month.
7-
* Provide a callback or listen for {@link module:Dota2.Dota2Client#event:leaguesInMonthData|leaguesInMonthData} for the Game Coordinator's response.
8-
* Requires the GC to be {@link module:Dota2.Dota2Client#event:ready|ready}.
9-
* @alias module:Dota2.Dota2Client#requestLeaguesInMonth
10-
* @param {number} [month=(new Date()).getMonth()] - Month (MM) you want to query data for. **IMPORTANT NOTE**: Month is zero-aligned, not one-aligned; so Jan = 00, Feb = 01, etc.
11-
* @param {number} [year=(new Date()).getFullYear()] - Year (YYYY) you want to query data for.
12-
* @param {number} [tier=0] - Search only for a specific tier of tournaments.
13-
* @param {module:Dota2~requestCallback} [callback] - Called with `err, CMsgDOTALeaguesInMonthResponse`
14-
*/
15-
Dota2.Dota2Client.prototype.requestLeaguesInMonth = function(month, year, tier, callback) {
16-
var _self = this;
17-
var now = new Date();
18-
19-
// Month & year default to current time values
20-
month = month === undefined ? now.getMonth() : month;
21-
year = year || now.getFullYear();
22-
tier = tier || 0;
23-
callback = callback || null;
24-
25-
this.Logger.debug("Sending CMsgDOTALeaguesInMonthRequest");
26-
27-
var payload = {
28-
'month': month,
29-
'year': year,
30-
'tier': tier
31-
};
32-
this.sendToGC( Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgGCLeaguesInMonthRequest,
33-
Dota2.schema.lookupType("CMsgDOTALeaguesInMonthRequest").encode(payload).finish(),
34-
onLeaguesInMonthResponse, callback);
35-
};
365

376
/**
387
* Requests info on all available official leagues from the GC.
@@ -67,25 +36,6 @@ Dota2.Dota2Client.prototype.requestTopLeagueMatches = function() {
6736
};
6837

6938
// Events
70-
/**
71-
* Emitted in response to a {@link module:Dota2.Dota2Client#requestLeaguesInMonth|request for the leagues in a given month}.
72-
* The leagues that are returned are those which have one or more matches in the given month.
73-
* They can however also have other matches in a different month.
74-
* @event module:Dota2.Dota2Client#leaguesInMonthData
75-
* @param {number} month - Month this data represents.
76-
* @param {number} year - Year this data represents
77-
* @param {Object[]} leagues - List of leagues that have matches in the given month
78-
* @param {number} leagues[].league_id - ID of the league
79-
* @param {Object[]} leagues[].schedule - The scheduled games in this league. Might contain matches in other months.
80-
* @param {number} leagues[].schedule[].block_id - ID of the schedule block
81-
* @param {number} leagues[].schedule[].start_time - Unix timestamp of the start time of this scheduled match
82-
* @param {boolean} leagues[].schedule[].finals - Whether or not this is a finals game
83-
* @param {string} leagues[].schedule[].comment - Comment about this scheduled block; often the team names & position in bracket
84-
* @param {Object[]} leagues[].schedule[].teams - The teams duking it out in this match
85-
* @param {number} leagues[].schedule[].teams[].team_id - ID of the team. Not every participating team seems to be hooked up to Dota 2's team system, so 0 entries can happen
86-
* @param {string} leagues[].schedule[].teams[].name - Name of the team
87-
* @param {external:Long} leagues[].schedule[].teams[].logo - Logo of the team
88-
*/
8939
/**
9040
* Emitted when the GC sends a `CMsgDOTALiveLeagueGameUpdate`.
9141
* @event module:Dota2.Dota2Client#liveLeagueGamesUpdate
@@ -119,21 +69,6 @@ Dota2.Dota2Client.prototype.requestTopLeagueMatches = function() {
11969
// Handlers
12070
var handlers = Dota2.Dota2Client.prototype._handlers;
12171

122-
var onLeaguesInMonthResponse = function onLeaguesInMonthResponse(message, callback) {
123-
callback = callback || null;
124-
var response = Dota2.schema.lookupType("CMsgDOTALeaguesInMonthResponse").decode(message);
125-
126-
if (response.eresult === 1) {
127-
this.Logger.debug("Received leagues in month response " + response.eresult);
128-
this.emit("leaguesInMonthData", response.month, response.year, response.leagues);
129-
if (callback) callback(null, response);
130-
} else {
131-
this.Logger.error("Received a bad leaguesInMonthResponse");
132-
if (callback) callback(response.eresult, response);
133-
}
134-
};
135-
handlers[Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgGCLeaguesInMonthResponse] = onLeaguesInMonthResponse;
136-
13772
var onLiveLeagueGameUpdate = function onLiveLeagueGameUpdate(message, callback) {
13873
callback = callback || null;
13974
var response = Dota2.schema.lookupType("CMsgDOTALiveLeagueGameUpdate").decode(message);

handlers/lobbies.js

+45-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ Dota2._lobbyOptions = {
8080
* @property {number} [custom_difficulty] - Difficulty of the custom game
8181
*
8282
* @property {external:Long} [custom_game_id] - 64bit ID of the custom game mode
83+
*
84+
* @property {LobbyDotaPauseSetting} [pause_setting=0] - Pause setting: 0 - unlimited, 1 - limited, 2 - disabled
8385
*/
8486

8587
// Methods
@@ -381,7 +383,7 @@ Dota2.Dota2Client.prototype.leavePracticeLobby = function(callback) {
381383
callback = callback || null;
382384
var _self = this;
383385

384-
/* Sends a message to the Game Coordinator requesting `matchId`'s match details. Listen for `matchData` event for Game Coordinator's response. */
386+
/* Sends a message to the Game Coordinator requesting to leave the lobby. Listen for `practiceLobby` event for Game Coordinator's response. */
385387
this.Logger.debug("Sending match CMsgPracticeLobbyLeave request");
386388

387389
var payload = {};
@@ -390,6 +392,25 @@ Dota2.Dota2Client.prototype.leavePracticeLobby = function(callback) {
390392
onPracticeLobbyResponse, callback);
391393
};
392394

395+
/**
396+
* Destroy the current lobby. Requires you to be the host.
397+
* Provide a callback or listen for the {@link module:Dota2.Dota2Client#event:lobbyDestroyed|lobbyDestroyed} event for the GC's response.
398+
* Requires the GC to be {@link module:Dota2.Dota2Client#event:ready|ready}.
399+
* @alias module:Dota2.Dota2Client#destroyLobby
400+
* @param {module:Dota2~requestCallback} [callback] - Called with `err, CMsgDOTADestroyLobbyResponse`
401+
**/
402+
Dota2.Dota2Client.prototype.destroyLobby = function(callback) {
403+
callback = callback || null;
404+
405+
/* Sends a message to the Game Coordinator requesting to destroy the lobby. Listen for `lobbyDestroyed` event for Game Coordinator's response. */
406+
this.Logger.debug("Sending match CMsgPracticeLobbyLeave request");
407+
408+
var payload = {};
409+
this.sendToGC( Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgDestroyLobbyRequest,
410+
Dota2.schema.lookupType("CMsgDOTADestroyLobbyRequest").encode(payload).finish(),
411+
onDestroyLobbyResponse, callback);
412+
}
413+
393414
/**
394415
* Abandons the current game.
395416
* Provide a callback or listen for the {@link module:Dota2.Dota2Client#event:practiceLobbyResponse|practiceLobbyResponse} event for the GC's response.
@@ -538,6 +559,12 @@ Dota2.Dota2Client.prototype.respondLobbyInvite = function(id, accept) {
538559
};
539560

540561
// Events
562+
/**
563+
* Event that's emitted when attempting to destroy the lobby
564+
* @event module:Dota2.Dota2Client#lobbyDestroyed
565+
* @param {CMsgDOTADestroyLobbyResponse.Result} result - Result code, 0 is SUCCESS, 1 is ERROR_UNKNOWN
566+
* @param {Object} response - The raw response object
567+
**/
541568
/**
542569
* Event that's emitted whenever the bot joins a lobby
543570
* @event module:Dota2.Dota2Client#practiceLobbyJoinResponse
@@ -578,6 +605,23 @@ Dota2.Dota2Client.prototype.respondLobbyInvite = function(id, accept) {
578605
// Handlers
579606
var handlers = Dota2.Dota2Client.prototype._handlers;
580607

608+
var onDestroyLobbyResponse = function onDestroyLobbyResponse(message, callback) {
609+
callback = callback || null;
610+
var lobbyDestroyed = Dota2.schema.lookupType("CMsgDOTADestroyLobbyResponse").decode(message);
611+
612+
this.Logger.debug("Received destroy lobby response "+lobbyDestroyed.result);
613+
this.emit("lobbyDestroyed", lobbyDestroyed.result, lobbyDestroyed);
614+
615+
if (callback) {
616+
if (lobbyDestroyed.result === Dota2.schema.lookupEnum("CMsgDOTADestroyLobbyResponse.Result").values.SUCCESS) {
617+
callback(null, lobbyDestroyed);
618+
} else {
619+
callback(lobbyDestroyed.result, lobbyDestroyed);
620+
}
621+
}
622+
}
623+
handlers[Dota2.schema.lookupEnum("EDOTAGCMsg").values.k_EMsgDestroyLobbyResponse ] = onDestroyLobbyResponse;
624+
581625
var onPracticeLobbyJoinResponse = function onPracticeLobbyJoinResponse(message, callback) {
582626
callback = callback || null;
583627
var practiceLobbyJoinResponse = Dota2.schema.lookupType("CMsgPracticeLobbyJoinResponse").decode(message);

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Dota2.schema = Protobuf.loadSync(folder.map(filename => __dirname + '/proto/' +
5757
* @fires module:Dota2.Dota2Client#event:practiceLobbyJoinResponse
5858
* @fires module:Dota2.Dota2Client#event:practiceLobbyListData
5959
* @fires module:Dota2.Dota2Client#event:practiceLobbyResponse
60+
* @fires module:Dota2.Dota2Client#event:lobbyDestroyed
6061
* @fires module:Dota2.Dota2Client#event:friendPracticeLobbyListData
6162
* @fires module:Dota2.Dota2Client#event:inviteCreated
6263
* @fires module:Dota2.Dota2Client#event:partyUpdate
@@ -77,7 +78,6 @@ Dota2.schema = Protobuf.loadSync(folder.map(filename => __dirname + '/proto/' +
7778
* @fires module:Dota2.Dota2Client#event:hallOfFameData
7879
* @fires module:Dota2.Dota2Client#event:playerCardRoster
7980
* @fires module:Dota2.Dota2Client#event:playerCardDrafted
80-
* @fires module:Dota2.Dota2Client#event:leaguesInMonthData
8181
* @fires module:Dota2.Dota2Client#event:liveLeagueGamesUpdate
8282
* @fires module:Dota2.Dota2Client#event:leagueData
8383
* @fires module:Dota2.Dota2Client#event:topLeagueMatchesData

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "dota2",
3-
"version": "5.2.0",
3+
"version": "6.0.0",
44
"dependencies": {
55
"deferred": "^0.7.8",
66
"long": "^3.2.0",
77
"merge": "^1.2.0",
8-
"moment": "^2.18.1",
8+
"moment": "^2.19.1",
99
"protobufjs": "^6.8.0",
1010
"steam": "^1.4.0",
1111
"winston": "^2.3.1"
1212
},
1313
"devDependencies": {
14-
"mocha": "^3.5.0",
15-
"should": "^13.0.0"
14+
"mocha": "^4.0.0",
15+
"should": "^13.1.3"
1616
},
1717
"scripts": {
1818
"update": "bash update_proto.sh",

proto/base_gcmessages.proto

-4
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ message CMsgReplicateConVars {
280280
repeated .CMsgConVarValue convars = 1;
281281
}
282282

283-
message CMsgConsumableExhausted {
284-
optional int32 item_def_id = 1;
285-
}
286-
287283
message CMsgItemAcknowledged {
288284
optional uint32 account_id = 1;
289285
optional uint32 inventory = 2;

0 commit comments

Comments
 (0)