Comments (9)
Hi
When you install Node.js you also install a tool called npm - which is the node package manager. You can install this library into your projects with simply npm install dota2
, and then use it as you would any other library.
If you're wanting to play around with the actual repository, just clone that somewhere on your drive and run npm install
in the test
directory - npm will open test/package.json
and install the required dependencies.
If you run into problems compiling dependencies (which is perhaps why you mentioned ursa - I too had problems with that on Windows iirc) then you need to set up the dependencies for node-gyp, and if you're on Windows you then run the npm install
commands through the visual studio command prompt.
I'm using linux as my development platform, so if you are indeed on Windows I might not be able to help you with everything. Regardless, let me know how you get on,
RJ
from node-dota2.
Thank you for your fast reply.
I am trying to bother you with as few noobish questions as possible. Using Windows this is what I did:
- I installed nodejs
- I followed this guide to make a steam trade bot http://www.youtube.com/watch?v=ggiTg5_ZO9g
- I went in '\GitHub\SteamBot\SteamBot' using git shell
- Typed
npm install -g node-gyp
- Typed
npm install dota2
At this point I got several errors about Python not present. While I had installed Python some time ago it was version 2.6.6. - I updated to 2.7.5 and did
npm install dota2
again.
Now I get errors about missing Visual C++ components. I do have Microsoft visual studio 2012 express, which should be sufficient. But apparently I need more?
Assuming I get this installed correctly do I add it to my SteamBot by adding a using node-dota2
in my handler file?
Will that be enough to use the create practice lobby command or do I have to make my own function to call that?
I suppose I have to assimilate the readme first.
from node-dota2.
Yes you will need Python for some of the installation scripts.
This library is built to be used with @seishun's node-steam, you write your bot with node-steam and initialize node-dota2 with an instance of that bot, then node-dota2 uses node-steam's API to send and receive messages via that bot. You cannot use this library with any C# or Steamkit-based projects like @Jessecar96's SteamBot.
The ./tests/
directory in the root of this repository is a kind of skeleton on using node-steam and node-dota2 together. Some more examples include MatchProvider-steam.js
from my matchurls project, steam_relay.js
from my irc_rbotson project (this is node-steam only, no dota 2 code), and also perhaps worth a look is bot.js
from my dotapls project - this project was my hacky experimentation with Dota 2 related code that prompted me to write this library.
If you choose to stick with SteamBot or a SteamKit-based project then I can't offer any help. I'm not aware of any dota2 libraries for SteamKit, nor am I experienced with it outside of occasionally browsing it's code for reference.
from node-dota2.
OK, regarding the visual studio components error earlier I found this http://stackoverflow.com/questions/14278417/cannot-install-node-modules-that-require-compilation-on-windows-7-x64-vs2012 , just have to add --msvs_version=2012
in the end.
I am getting confused. The reason I mentioned ursa was because this line from node-steam Windows note: this module depends on ursa. Follow its installation prerequisites first.
I'll just add it as well I guess.
This you write your bot with node-steam
is the critical part for me. I have some experience in coding, but I just don't understand what are the initial steps to get something working. If you can direct me to any tutorials/guides how to work with node-steam I would be very grateful.
from node-dota2.
I finally made some progress. I will post a summary of what I did, hopefully will make the life easier for anybody who stumbles here unprepared like I did.
- You need Nodejs ( http://nodejs.org/ ). In one sentence - it is something that runs javascript as console application
- With the installation of node you should be able to use the
npm
command in your console, I don't remember if I did anything else to make that working
This node-dota2 is dependant on node-steam. Node-steam has its own dependencies, which for windows you have to install manually. - Get Visual studio (there is a free microsoft visual studio called 'express' , you will need to add --msvs_version=2012 for VS2012 when you install stuff with npm)
- Get Python . I am working with 2.7.5, (2.6 didn't do it for me)
- Get Openssl
Last 2 steps are needed because node-steam requires https://github.com/Obvious/ursa to run on windows and ursa requires those 2. Things might change over time so check node-steam and ursa descriptions on github. - Go to the folder for your project using the console
- Type
npm install ursa --msvs_version=2012
to install first dependency - Type
npm install steam --msvs_version=2012
to install second dependency - Download this project and put its contents inside the newly created node_modules folder
- I needed to copy the folder protobuf from
\node_modules\steam\node_modules
to\node_modules
to makevar dota2 = require('dota2')
to work. Not sure why... - Copy the file
\node_modules\steam\example.js
to the root of your project folder - Edit the bot.logOn at line 10 to have your bot's username and password. I had to remove steam guard from my bot cause it was asking for a new code in every launch.
- inside the project folder type
node example.js
in the console and enjoy your bot
Anyway that is how I finally got node-steam to work.
The reason why I am not closing this issue is because I get an error when I add Dota2.launch();
to the node-steam example.js. I have added
var steamClient = new Steam.SteamClient(),
dota2 = require('dota2'),
Dota2 = new dota2.Dota2Client(steamClient, true);
, but I get the following error: http://pastebin.com/YTr05Uz2
from node-dota2.
You need to create a node-steam client and log into Steam with it before node-dota2 can do anything; node-dota2 piggybacks the client, but it doesn't manage it for you.
Here is a simple skeleton:
var steam = require("steam"),
util = require("util"),
fs = require("fs"),
dota2 = require("dota2"),
bot = new steam.SteamClient(),
Dota2 = new dota2.Dota2Client(bot, true);
global.config = require("./config");
/* Steam logic */
var onSteamLogOn = function onSteamLogOn(){
bot.setPersonaState(steam.EPersonaState.Busy); // to display your bot's status as "Online"
bot.setPersonaName(config.steam_name); // to change its nickname
util.log("Logged on.");
Dota2.launch();
},
onSteamSentry = function onSteamSentry(sentry) {
util.log("Received sentry.");
require('fs').writeFileSync('sentry', sentry);
},
onSteamServers = function onSteamServers(servers) {
util.log("Received servers.");
fs.writeFile('servers', JSON.stringify(servers));
};
/* Dota 2 logic */
var onD2Ready = function onD2Ready () {
console.log("Node-dota2 ready.");
/* Dota 2 is ready; do things. */
},
onD2Unready = function onD2Unready(){
console.log("Node-dota2 unready.");
/* Dota 2 is became unready (lost connection to GC / other potential reasons); do any cleanup, if necessary, here. */
},
onD2UnhandledMessage = function onD2UnhandledMessage (kMsg) {
util.log("UNHANDLED MESSAGE " + kMsg);
}
/* Hook up event listeners */
Dota2
.on("ready", onD2Ready)
.on("unready", onD2Unready)
.on("unhandled", onD2UnhandledMessage);
bot.on("loggedOn", onSteamLogOn)
.on('sentry', onSteamSentry)
.on('servers', onSteamServers);
/* Log in to Steam*/
bot.logOn({
"accountName": config.steam_user,
"password": config.steam_pass,
"authCode": config.steam_guard_code,
"shaSentryfile": fs.readFileSync('sentry')
});
// Configure and mv to config.js
var config = {};
config.steam_name = "";
config.steam_user = "";
config.steam_pass = "";
config.steam_guard_code = "";
module.exports = config;
from node-dota2.
I am not sure if I understand.
The skeleton that you provide looks a lot like the index.js from the test folder but I can't run either and both provide the same error - http://pastebin.com/5GJ6rjyg
I can't find a file called sentry anywhere.
from node-dota2.
Make a blank file called 'sentry'. Its simply a place to store a token that identifies the client with Steam Guard - so if you use Steam Guard you only need to verify the logon once.
If you're not using steam guard you can just comment out the related lines.
from node-dota2.
Thank you!
from node-dota2.
Related Issues (20)
- Watch/interact with replays HOT 3
- Not logging when SteamGuard is off
- multiple lobby
- bot to spectators HOT 1
- Grabbing spectated match stats
- Tips for creating new handler? Want to get daily draft trivia
- requestPracticeLobbyList returns only 5 results
- after leaving lobby issues
- Bot doesn't receive "practiceLobbyUpdate" event after lobby was launched HOT 3
- Bot is not installed HOT 2
- "practiceLobbyUpdate" no longer shows members HOT 4
- practiceLobbyUpdate data missing HOT 4
- .
- Regional channel list HOT 1
- Can I create an auto chess lobby now ? HOT 1
- Bot leaves lobby, leaves unassigned player (black box) HOT 1
- Bot not getting data after leaving game/game that is finished
- How to get lobby result ( members - team win - and others... ) ? HOT 1
- Cannot find module 'protobufjs' HOT 2
- Proposal: Archive node-dota2 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-dota2.