update to node 16; upd. deps

* add discord.js optionals
 * cloudno.de --> fly.io
This commit is contained in:
Smith
2022-08-18 21:34:18 +02:00
parent 439ce44a5b
commit 381d1d8f48
7 changed files with 2175 additions and 306 deletions

View File

@@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
branches:
- cloud
- master
jobs:
push:

View File

@@ -6,7 +6,7 @@ The main goals of this repo:
1. create a (simple, but capable) service/bot to monitor game servers
1. get gamedig & steam api server info (_eg.: server name, map, players, etc._)
1. relay real time server information to various channels via APIs (_eg.: discord, telegram, slack etc._)
1. should be able to host on a free service (_target atm. is cloudno.de (node.js 12.20.1)_)
1. should be able to host on a free service (_target atm. is fly.io (node.js 16)_)
1. graciously add more features based on community feedback via [discord](https://discord.gg/4tsbftsGJz) and [github](https://github.com/a-sync/game-server-watcher/discussions/new?category=ideas-requests)
<details>
@@ -23,7 +23,7 @@ The main goals of this repo:
</details>
# Project Status
The code itself is stable and continuously tested/deployed from the cloud branch.
The code itself is stable and continuously tested/deployed from the master branch.
The project is in a very early stage. More detailed customization options and features will be added as requested.
@@ -49,7 +49,7 @@ The project is in a very early stage. More detailed customization options and fe
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See [deployment](#deployment) for notes on how to deploy the project on a live system.
## Requirements
[node.js](https://nodejs.org/) _(version 12.20.0 or later)_
[node.js](https://nodejs.org/) _(version 16.9.0 or later)_
## Getting the source
This project is [hosted on github](https://github.com/a-sync/game-server-watcher). You can clone this project directly using this command:
@@ -59,7 +59,6 @@ git clone git@github.com:a-sync/game-server-watcher.git
```
The latest source and build can also be downloaded as a [zip archive](https://github.com/a-sync/game-server-watcher/archive/refs/heads/master.zip).
(The [cloud branch zip archive](https://github.com/a-sync/game-server-watcher/archive/refs/heads/cloud.zip) also includes all the required dependencies.)
## Installation
Use npm or yarn to install/update all the dependencies:
@@ -119,7 +118,7 @@ If the original message created by the bot gets deleted, you need to flush the b
_The bot has no cleanup functionality, left over messages must be removed manually._
# Deployment
Check the wiki page for detailed instructions on [how to setup a self deploying free cloud instance at cloudno.de](https://github.com/a-sync/game-server-watcher/wiki/Free-hosting-via-cloudno.de).
Check the wiki page for detailed instructions on [how to setup a self deploying free cloud instance at fly.io](https://github.com/a-sync/game-server-watcher/wiki/Free-hosting-via-fly.io).
<p align="center">
<!--<a href="https://heroku.com/deploy?template=https%3A%2F%2Fgithub.com%2Fa-sync%2Fgame-server-watcher"><img src="https://www.herokucdn.com/deploy/button.svg" height="32" alt="Deploy to Heroku"></a>//TODO: support ephemeral storage-->
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fa-sync%2Fgame-server-watcher%2Fmaster%2Fazuredeploy.json"><img src="https://aka.ms/deploytoazurebutton" height="32" alt="Deploy to Azure"></a>
@@ -209,3 +208,4 @@ All other libraries and dependencies are listed in the _package.json file (depen
* https://github.com/GiyoMoon/steam-server-query
* https://github.com/Fabricio-191/valve-server-query
* https://github.com/sbuggay/srcds-info-proxy
* https://github.com/DiscordGSM/DiscordGSM

2424
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "game-server-watcher",
"version": "1.0.0",
"version": "2.0.0",
"description": "A simple discord/telegram bot that can be hosted on a free service to monitor your game servers and players in style 😎",
"main": "src/server",
"scripts": {
@@ -8,7 +8,7 @@
"dev": "nodemon -e ts --exec \"npx tsc --incremental && node ./dist/server.js || exit 1\"",
"build": "tsc"
},
"keywords": [],
"keywords": ["game-server", "gamedig", "discord-bot", "telegram-bot", "steam-api"],
"repository": {
"type": "git",
"url": "git://github.com/a-sync/game-server-watcher.git"
@@ -17,20 +17,26 @@
"license": "AGPL-3.0-or-later",
"dependencies": {
"@commonify/lowdb": "^3.0.0",
"discord.js": "^12.5.3",
"dotenv": "^16.0.1",
"got": "^11.8.5",
"grammy": "^1.9.0",
"mustache": "^4.2.0",
"node8-gamedig": "^4.0.5"
"axios": "^0.27.2",
"discord.js": "^14.3.0",
"dotenv": "^16.0.2",
"gamedig": "^4.0.5",
"grammy": "^1.11.0",
"mustache": "^4.2.0"
},
"devDependencies": {
"@types/gamedig": "^3.0.2",
"@types/node": "12.20",
"nodemon": "^2.0.18",
"typescript": "^4.7.4"
"@types/node": "^16.9.0",
"nodemon": "^2.0.19",
"typescript": "^4.8.2"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
"node": ">=16.9.0"
},
"optionalDependencies": {
"bufferutil": "^4.0.6",
"erlpack": "github:discord/erlpack",
"utf-8-validate": "^5.0.9",
"zlib-sync": "^0.1.7"
}
}

View File

@@ -1,5 +1,3 @@
const id = s => document.getElementById(s);
let configEditor;
$(async () => {
const gswFeatures = await fetchApi('GET', 'features');
@@ -30,7 +28,7 @@ $(async () => {
// Configuration
const gswConfig = await fetchApi('GET', 'config');
if (gswConfig && gswConfig.config) {
configEditor = new JSONEditor(id('config-form'), {
configEditor = new JSONEditor(document.getElementById('config-form'), {
"theme": "bootstrap4",
"iconlib": "fontawesome5",
"object_layout": "normal",
@@ -388,6 +386,7 @@ function notif(type, html1, html2, html3, dismissable) {
function activateMenu(target) {
if (!target) {
const id = s => document.getElementById(s);
target = id('top-menu-configuration');
if (document.location.hash.length > 1) {
const hashTargetMenu = id('top-menu-' + document.location.hash.slice(1));

View File

@@ -8,8 +8,8 @@ import 'dotenv/config';
import { GameServerConfig, main, readConfig, updateConfig } from './watcher';
const CACHE_MAX_AGE = parseInt(process.env.CACHE_MAX_AGE || '0', 10);
const APP_HOST = process.env.HOST || process.env.APP_HOST || '0.0.0.0';
const APP_PORT = parseInt(process.env.PORT || process.env.APP_PORT || '8080', 10);
const APP_HOST = process.env.HOST || '0.0.0.0';
const APP_PORT = parseInt(process.env.PORT || '8080', 10);
const SECRET = process.env.SECRET || 'secret';
const DATA_PATH = process.env.DATA_PATH || './data/';
const DBG = Boolean(process.env.DBG || false);
@@ -114,8 +114,8 @@ createServer(async (req, res) => {
res.writeHead(404, { 'Content-Type': 'text/html' });
res.end('<html><head></head><body>404 &#x1F4A2</body></html>');
}
}).listen(APP_PORT, APP_HOST, () => {
console.log('Web service started %s:%s', APP_HOST, APP_PORT);
}).listen(PORT, HOST, () => {
console.log('Web service started %s:%s', HOST, PORT);
});
main().then(l => {

View File

@@ -4,7 +4,7 @@ import { GameServer, initDb, saveDb } from './game-server';
import * as discordBot from './discord-bot';
import * as telegramBot from './telegram-bot';
const REFRESH_TIME_MINUTES = parseInt(process.env.REFRESH_TIME_MINUTES || '5', 10);//DEPRECETED
const REFRESH_TIME_MINUTES = parseInt(process.env.REFRESH_TIME_MINUTES || '2', 10);
const DISCORD_BOT_TOKEN = process.env.DISCORD_BOT_TOKEN || '';
const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN || '';
const DATA_PATH = process.env.DATA_PATH || './data/';