diff --git a/TODO b/TODO index bf3f8d1..887e543 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,4 @@ +// serve a list of game servers and some basic info // flush game server specific (d/t) data //v4 diff --git a/package-lock.json b/package-lock.json index 585d072..2a489ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "game-server-watcher", - "version": "3.1.2", + "version": "3.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "game-server-watcher", - "version": "3.1.2", + "version": "3.1.3", "license": "AGPL-3.0-or-later", "dependencies": { "@slack/bolt": "^3.17.1", diff --git a/package.json b/package.json index be79744..04a390d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "game-server-watcher", - "version": "3.1.2", + "version": "3.1.3", "description": "A simple discord/telegram/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎", "exports": "./dist/server.js", "type": "module", diff --git a/public/game-server-config.schema.json b/public/game-server-config.schema.json index 5c5287f..281ed84 100644 --- a/public/game-server-config.schema.json +++ b/public/game-server-config.schema.json @@ -201,6 +201,30 @@ "grid_columns": 12 } }, + "description": { + "title": "Description", + "type": "string", + "format": "markdown", + "options": { + "simplemde": { + "spellChecker": false, + "toolbar": [ + "bold", + "italic", + "|", + "unordered-list", + "ordered-list", + "|", + "code", + "link", + "quote", + "|", + "side-by-side", + "preview" + ] + } + } + }, "givenPortOnly": { "title": "givenPortOnly", "description": "Only attempt to query server on given port.", diff --git a/public/index.html b/public/index.html index 748ebb7..ab428e0 100644 --- a/public/index.html +++ b/public/index.html @@ -15,19 +15,19 @@ + + diff --git a/public/main.js b/public/main.js index 15b55a7..fe093f4 100644 --- a/public/main.js +++ b/public/main.js @@ -45,7 +45,7 @@ $(async () => { "use_default_values": true, "ajax": true, "ajaxCredentials": false, - "ajax_cache_responses": true, + "ajax_cache_responses": !Boolean(location.hostname === "localhost" || location.hostname === "127.0.0.1"), "ajax_cache_buster": 'gsw-v' + gswFeatures.features.version + '+gamedig-v' + gswFeatures.features.gamedig, "disable_edit_json": false, "disable_collapse": true, diff --git a/src/discord-bot.ts b/src/discord-bot.ts index d59d42b..eaa3216 100644 --- a/src/discord-bot.ts +++ b/src/discord-bot.ts @@ -178,6 +178,8 @@ class ServerInfoMessage { fields.push({ name: 'Players', value: String(gs.info.playersNum + '/' + gs.info.playersMax), inline: true}); fields.push({ name: 'Address', value: String(gs.info.connect)}); + if (gs.config.description) fields.push({ name: 'Description', value: String(gs.config.description).slice(0, 1024)}); + if (showPlayersList && gs.info?.players.length > 0) { const pNames: string[] = []; const pTimes: string[] = []; diff --git a/src/slack-bot.ts b/src/slack-bot.ts index c854a3b..fc07f2c 100644 --- a/src/slack-bot.ts +++ b/src/slack-bot.ts @@ -202,6 +202,17 @@ class ServerInfoMessage { }); } + if (gs.config.description) { + text += '\r\nDescription:\r\n' + String(gs.config.description).slice(0, 1024); + blocks.push({ + type: 'section', + fields: [{ + type: 'mrkdwn', + text: '*Description* \r\n' + String(gs.config.description).slice(0, 1024) + }] + }); + } + if (showPlayersList && gs.info?.players.length > 0) { const pNames: string[] = []; for (const p of gs.info?.players) { diff --git a/src/telegram-bot.ts b/src/telegram-bot.ts index 0898421..ef7493c 100644 --- a/src/telegram-bot.ts +++ b/src/telegram-bot.ts @@ -131,6 +131,7 @@ class ServerInfoMessage { const chart = showGraph ? '[📈](' + gs.history.statsChart() + ')' : ''; let infoText = this.escapeMarkdown(gs.niceName) + ' offline...'; + if (gs.info && gs.online) { infoText = [ this.escapeMarkdown(gs.niceName), @@ -139,6 +140,8 @@ class ServerInfoMessage { 'Players ' + gs.info.playersNum + '/' + gs.info.playersMax ].join('\n'); + if (gs.config.description) infoText += 'Description:\n' + String(gs.config.description).slice(0, 1024) + '\n'; + if (showPlayersList && gs.info.players.length > 0) { const pnArr: string[] = []; for (const p of gs.info.players) { @@ -154,6 +157,7 @@ class ServerInfoMessage { } } } + infoText += chart; try { diff --git a/src/watcher.ts b/src/watcher.ts index 95d861d..0dd605c 100644 --- a/src/watcher.ts +++ b/src/watcher.ts @@ -39,6 +39,7 @@ export interface GameServerConfig { updateIntervalMinutes?: number;//5 graphHistoryHours?: number;//12 timezoneOffset?: number;//0 + description?: string; discord?: DiscordConfig[]; telegram?: TelegramConfig[]; slack?: SlackConfig[];