Skip to content

Gets the scores of live CSGO matches in real time.

Notifications You must be signed in to change notification settings

nobodhi/csgo-livegames

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HLTV Livescore

Contents

Introduction

This is a wrapper for andrewda's hltv-scorebot, v. 1.0.0. A cheerio web scraper monitors HLTV for live games and socket-io child processes are forked to monitor scores for each new set of live games:

sequenceDiagram
Livegames ->> Livegames: scrapeMatchPage(hltv)
Livegames --x API: POST {live, upcoming games}
Livegames ->> Livescore: getLiveGames()
Livescore -->> Scorebot: ReadyForScores()
Note right of API: Spawns a new Socket.io-client connection to HLTV's Scorebot server.
Scorebot --x Livescore: {live scores}
Livescore --x API: Post {live scores}
Loading

UML Sequence Diagram

Getting Started

Install with npm:

$ git clone path-to-this-repo
$ npm install

Usage

node index.js // currently used for testing
node serverParent.js // this is the current entry point (sorry)

This project also comes with PM2 ecosystem files. They're in the root of the project folders. Use them like this:

pm2 start ecosystem_win.json --env=development

The ecosystem files provide you with three environments: development, staging, and production. Each environment will also post to a different API (if you do not assign an API it will default to jsonplaceholder.com). You can set environment variables manually, e.g. on Windows:

// set environment to development:
set NODE_ENV=development
set API_URL=
set API_KEY=
node serverParent.js

And on Linux you can execute this as a shell script:

$ #!/bin/bash
$ # must save this file in Unix format
$ cd 
$ cd livescore
$ sudo NODE_ENV=staging pm2 start serverParent.js
$ cd
$ cd livegames
$ sudo NODE_ENV=staging pm2 start serverParent.js
$ # TODO use an environment variable.

Methods

Constructor([options])

  • options - An optional object containing some of the following options

  • listid - The game's listid

  • url - The URL to listen on. Defaults to https://scorebot-secure.hltv.org

  • port - The port to listen on. Defaults to 80

Constructs a new Livescore. You will be automatically connected to the HLTV scorebot server. The game with the specified listid will be automatically started if provided. If not provided, you must specify them using them using the start() method.

Events

Events emit an object containing the parameters listed under each event.

raw

Uses socket.io-wildcard to emit everything coming from HLTV server.

About

Gets the scores of live CSGO matches in real time.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published