Giter Site home page Giter Site logo

hldm-state-bot's Introduction

Death Match state checking bot

Bot checks game server state each 3 minutes and reports if something changed: how many players play, which map, server unavailable.

Based on python-a2s and should support Valve Source and GoldSource servers:

  • Half-Life (that's for what I developed bot and tested)
  • Half-Life 2
  • Team Fortress 2
  • Counter-Strike 1.6
  • Counter-Strike: Global Offensive
  • ARK: Survival Evolved
  • Rust

Commands

/reg hostname port to set up server data

/state to get state right now

Settings

Token

Token should be present in env. You can write it in .env file

BOT_TOKEN = 'AVAKADAKADABRA'

or pass as container arguments

docker build -t hldm-state-bot .
docker run --name hldm-state-bot -e BOT_TOKEN='AVAKADAKADABRA' -d hldm-state-bot:latest

Please ensure that only one bot work with the same token at one time!

Time between server state checks

By the same way define BOT_PERIOD. By default 42 seconds

Development prerequisites

python -m virtualenv .venv
.venv/Scripts/activate
pip install -r .\requirements.txt

Deployment

Clone repo into some server directory, as example into ~/docker-server/hldm-state-bot

Create docker-compose.yml

version: '3.9'

services:
  hldm-state-bot:
    container_name: hldm-state-bot
    hostname: hldm-state-bot
    build:
      context: .
      dockerfile: Dockerfile

    volumes:
      - data:/app/data
    environment:
      - BOT_TOKEN=AVAKADAKADABRA
      - BOT_PERIOD=30
    restart: on-failure:7
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 200M

volumes:
  data:

networks:
  default:
    external:
      name: network

Create .git/hooks/post-merge

#!/bin/sh

docker-compose up -d --build

And make it executable. Now you can run git pull to deploy from master

Or you can automate with crontab.

Run crontab -e and write schedule

*/15 * * * * git -C ~/docker-server/hldm-state-bot pull

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.