Code Monkey home page Code Monkey logo

node-dota2-bot's Introduction

node-dota2-bot

This project is a fork from Crazy-Duck's original bot

Wrapper around the node-dota2 library which handles all log-in shenanigans. This basic DotaBot class prepares an object for connection to Steam and the Dota2 Game Coordinator. As soon as connect(callback) is called, the DotaBot connects to Steam and the Dota2 GC. As soon as all connections are made, the queue is started. From then on, all scheduled functions will be executed as soon as the GC is available.

npm Dependency Status

Usage

Installation

Run npm install node-dota2-bot to install the package or clone from GitHub

Properties

  • steamClient The steam client used to interact with Steam. See node-steam for details.
  • steamUser The steam user for account-related functionality, including logon.. See node-steam for details.
  • steamFriends The steam friends for community functionality, such as chats and friend messages. See node-steam for details.
  • Dota2 The Dota2Client for interaction with the Dota2 Game Coordinator. See node-dota2 for details.

Getters / Setters

  • state The current state of the queue (only getter).
  • rate_limit The current rate limiting factor, i.e. the time in milliseconds between requests.
  • backoff The current backoff factor used for exponential backoff.

Methods

constructor (logonDetails, debug, debugMore)

  • logonDetails Object with two properties, account_name and password
  • debug Boolean indicating whether or not basic debug info should be shown
  • debugMoreBoolean indicating whether or not advanced debug info should be shown

Creates a new DotaBot ready to connect to Steam and the Dota2 GC

connect ()

Connect to Steam and the Dota2 GC. DotaBot will keep the connections alive until disconnect() is called

disconnect ()

Disconnect from Steam and the Dota2 GC.

schedule(fn)

  • fn Function to schedule for execution as soon as the GC is available

Example

Script

'use strict'
const DotaBot = require("DotaBot");

var logonDetails = {account_name: 'username', password:'password'};
var bot = new DotaBot(logonDetails, true, false);
bot.Dota2.on("profileCardData", function (accId, data) {
    console.log(JSON.stringify(data));
});
bot.connect();
bot.schedule(()=>{bot.Dota2.requestProfileCard(63470426);});
setTimeout(()=>{bot.disconnect();}, 25000);

Output

19 May 12:16:07 - Blocking queue
19 May 12:16:07 - Scheduling job
19 May 12:16:07 - Connected, logging on..
19 May 12:16:07 - Logged on with id = **********
19 May 12:16:07 - Launching Dota 2
19 May 12:16:07 - Received servers.
19 May 12:16:07 - sentryfile saved
19 May 12:16:08 - Sending ClientHello
19 May 12:16:08 - Received client welcome.
19 May 12:16:08 - Activating queue
19 May 12:16:08 - Executing job
19 May 12:16:08 - Sending profile card request
19 May 12:16:08 - Queue is empty, going idle
19 May 12:16:09 - Cache subscribed, type 7
19 May 12:16:09 - Unknown cache ID: 7
19 May 12:16:09 - Received profile card data for: 63470426
{"account_id":63470426,"background_def_index":0, ...
19 May 12:16:26 - Exiting Dota 2

node-dota2-bot's People

Contributors

crazy-duck avatar t0shiii avatar

Stargazers

 avatar  avatar  avatar  avatar

Forkers

dotabod

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.