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

Commit

Permalink
Merge pull request #412 from Arcana/dev
Browse files Browse the repository at this point in the history
Update to 4.2.0
  • Loading branch information
Crazy-Duck authored Jan 5, 2017
2 parents a84f437 + 7ab080f commit 69f2596
Show file tree
Hide file tree
Showing 30 changed files with 809 additions and 418 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- "6.7.0"
- "4.6.0"
- "7.2.0"
- "6.9.1"
51 changes: 44 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ You can launch the tests by running the file with mocha.
###AccountID
The current steam ID of the SteamClient converted to Dota 2 Account ID format. Not available until `launch` is called.

###Inventory (hats, not in-match items)
The current player inventory (see CSOEconItem). Null if the bot hasn't received inventory information yet.

###Lobby
The current lobby object (see CSODOTALobby). Null if the bot is not in a lobby.

Expand Down Expand Up @@ -111,7 +114,7 @@ Attempts to delete an item. Requires the GC to be ready (listen for the `ready`


### Chat
**_Limited Steam accounts cannot interact with chat!_**
**_In order to send a message, your account must 1. be non-Limited Steam Account 2. have at least 5 Trophy Level_**

#### joinChat(channel_name, [channel_type])
* `channel_name` - A string for the channel name.
Expand Down Expand Up @@ -510,7 +513,22 @@ Requests info on all available official leagues from the GC. Listen for `leagueD

Sends a message to the Game Coordinator requesting the top league matches. Listen for the `topLeagueMatchesData` event for the Game Coordinator's response (cannot take a callback because of Steam's backend). Requires the GC to be ready (listen for the `ready` event before calling).

### Fantasy
#### requestPlayerCardRoster(league_id, timestamp, [callback])
* `league_id` - ID of the league for which you're requesting your player card roster
* `timestamp` - timestamp of the day for which you want your player card roster
* `[callback]` - optional callback` returns args: `err` response`.

Sends a message to the Game Coordinator requesting your fantasy line-up for a specific day of a given tournament. Listen for the `playerCardRoster` event for the Game Coordinator's response. Requires the GC to be ready (listen for the `ready` event before calling).

#### draftPlayerCard(league_id, timestamp, slot, player_card_id, [callback])
* `league_id` - ID of the league for which you're drafting a player card
* `timestamp` - timestamp of the day for which you want to draft a player card
* `slot` - Slot in the draft which you want to fill
* `player_card_id` - Item ID of the player card you want to draft
* `[callback]` - optional callback` returns args: `err` response`.

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. Listen for the `playerCardDrafted` event for the Game Coordinator's response. Requires the GC to be ready (listen for the `ready` event before calling).
### SourceTV

#### requestSourceTVGames([filterOption])
Expand Down Expand Up @@ -814,33 +832,27 @@ Here are the groups at the time of this sentence being written (with unecessary

Emitted when the GC responds to the `requestTopFriendMatches` method.


### `practiceLobbyUpdate` (`lobby`)
* `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.


### `lobbyInviteCleared` ()

Emitted when the Lobby Invite is cleared, for example when
accepting/rejecting it or when the lobby is closed.



### `practiceLobbyJoinResponse`(`result`, `practiceLobbyJoinResponse`)
* `result` - The result object from `practiceLobbyJoinResponse`.
* `practiceLobbyJoinResponse` - The raw response object.

Emitted when the GC responds to `joinPracticeLobby` method.


### `practiceLobbyCleared` ()

Emitted when leaving a lobby (aka, the lobby is cleared). This can
Expand Down Expand Up @@ -972,6 +984,31 @@ TODO

Emitted when the GC responds to the `requestSourceTVGames` method. Multiple events are emitted when `requestSourceTVGames` is passed with `start_game` > 0 or with one or more `lobby_id`s.


### `inventoryUpdate` (`inv`)
* `inv` - Player inventory

Emitted when the GC sends an inventory 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 change was made to your inventory (e.g. drop)
Note that the `Inventory` property will be the old value until after this event
completes to allow comparison between the two.

### `playerCardRoster` (`playerCardRoster`)
* `playerCardRoster` - Fantasy challenge line-up for a specific day
* `result` - Status code indicating whether or not the request was succesful (0 = SUCCESS)
* `player_card_item_id` - Item ID of the player card. Can be used to cross-reference with `Inventory`
* `score` - Score the card got for this specific day
* `finalized` - Whether or not the matches for this day are over
* `percentile` - Percentile of all players your score falls in

Emitted when the GC responds to the `requestPlayerCardRoster` method.

### `playerCardDrafted` (`result`)
* `result` - Status code indicating whether or not the card got drafted (0 = SUCCESS)

Emitted when the GC responds to the `draftPlayerCard` method.

## Enums
### ServerRegion
* `UNSPECIFIED: 0`
Expand Down
12 changes: 8 additions & 4 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ global.config = require("./config");
var onSteamLogOn = function onSteamLogOn(logonResp) {
if (logonResp.eresult == steam.EResult.OK) {
steamFriends.setPersonaState(steam.EPersonaState.Busy); // to display your steamClient's status as "Online"
steamFriends.setPersonaName("dhdeubot"); // to change its nickname
steamFriends.setPersonaName(global.config.steam_name); // to change its nickname
util.log("Logged on.");
Dota2.launch();
Dota2.on("ready", function() {
Expand Down Expand Up @@ -146,20 +146,23 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
// Dota2.setGuildAccountRole(guildId, 75028261, 3);
});
Dota2.on("unhandled", function(kMsg) {
util.log("UNHANDLED MESSAGE " + kMsg);
util.log("UNHANDLED MESSAGE " + dota2._getMessageName(kMsg));
});
// setTimeout(function(){ Dota2.exit(); }, 5000);
}
},
onSteamServers = function onSteamServers(servers) {
util.log("Received servers.");
fs.writeFile('servers', JSON.stringify(servers));
fs.writeFile('servers', JSON.stringify(servers), (err)=>{
if (err) {if (this.debug) util.log("Error writing ");}
else {if (this.debug) util.log("");}
});
},
onSteamLogOff = function onSteamLogOff(eresult) {
util.log("Logged off from Steam.");
},
onSteamError = function onSteamError(error) {
util.log("Connection closed by server.");
util.log("Connection closed by server: "+error);
};

steamUser.on('updateMachineAuth', function(sentry, callback) {
Expand All @@ -178,6 +181,7 @@ var logOnDetails = {
"password": global.config.steam_pass,
};
if (global.config.steam_guard_code) logOnDetails.auth_code = global.config.steam_guard_code;
if (global.config.two_factor_code) logOnDetails.two_factor_code = global.config.two_factor_code;

try {
var sentry = fs.readFileSync('sentry');
Expand Down
48 changes: 44 additions & 4 deletions examples/example2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ global.config = require("./config");
var onSteamLogOn = function onSteamLogOn(logonResp) {
if (logonResp.eresult == steam.EResult.OK) {
steamFriends.setPersonaState(steam.EPersonaState.Busy);
steamFriends.setPersonaName("Dota 2 Bot");
steamFriends.setPersonaName(global.config.steam_name);
util.log("Logged on.");

Dota2.launch();
Expand Down Expand Up @@ -71,6 +71,7 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {

// MATCH

// Request the details of a certain match
var CheckMatchID = 1944132605;
var checkingMatch = 0;

Expand All @@ -79,6 +80,27 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
util.log(JSON.stringify(data));
});
}

// Request the 50 most recent matches
var checkingMatches = 0;
if(checkingMatches == 1){
Dota2.requestMatches({
"matches_requested": 25,
"tournament_games_only": false,
"skill": 1
}, (result,response) => {
response.matches.map(match => console.log(""+match.match_id));
var lastID = response.matches[24].match_id - 1;
Dota2.requestMatches({
"matches_requested": 25,
"start_at_match_id": lastID,
"tournament_games_only": false,
"skill": 1
}, (result, response)=>{
response.matches.map(match => console.log(""+match.match_id));
});
});
}

// ----------------------------------

Expand All @@ -105,7 +127,7 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
}

Dota2.createPracticeLobby(lobbyPassword, properties, function(err, data){
// util.log(JSON.stringify(data));
util.log(JSON.stringify(data));
});
}

Expand Down Expand Up @@ -142,6 +164,20 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
});
}

// ----------------------------------

// FANTASY

var fantasyCards = 0;

if (fantasyCards == 1) {
Dota2.on("inventoryUpdate", inventory => {
// Time-out so inventory property is updated
setTimeout(()=>{
Promise.all(Dota2.requestPlayerCardsByPlayer()).then(cards => console.log(cards));
}, 1000);
});
}
});

Dota2.on("unready", function onUnready() {
Expand All @@ -153,13 +189,16 @@ var onSteamLogOn = function onSteamLogOn(logonResp) {
});

Dota2.on("unhandled", function(kMsg) {
util.log("UNHANDLED MESSAGE #" + kMsg);
util.log("UNHANDLED MESSAGE " + dota2._getMessageName(kMsg));
});
}
},
onSteamServers = function onSteamServers(servers) {
util.log("Received servers.");
fs.writeFile('servers', JSON.stringify(servers));
fs.writeFile('servers', JSON.stringify(servers), (err) => {
if (err) {if (this.debug) util.log("Error writing ");}
else {if (this.debug) util.log("");}
});
},
onSteamLogOff = function onSteamLogOff(eresult) {
util.log("Logged off from Steam.");
Expand All @@ -181,6 +220,7 @@ var logOnDetails = {
"password": global.config.steam_pass,
};
if (global.config.steam_guard_code) logOnDetails.auth_code = global.config.steam_guard_code;
if (global.config.two_factor_code) logOnDetails.two_factor_code = global.config.two_factor_code;

try {
var sentry = fs.readFileSync('sentry');
Expand Down
Loading

0 comments on commit 69f2596

Please sign in to comment.