remove steam://connect/ prefix of server connect uri

This commit is contained in:
Smith
2023-12-28 21:26:33 +01:00
parent 4ab9be3921
commit ecdd6db6a0
6 changed files with 9 additions and 19 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "game-server-watcher",
"version": "2.3.0",
"version": "2.4.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "game-server-watcher",
"version": "2.3.0",
"version": "2.4.0",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@commonify/lowdb": "^3.0.0",

View File

@@ -1,6 +1,6 @@
{
"name": "game-server-watcher",
"version": "2.4.0",
"version": "2.5.0",
"description": "A simple discord/telegram/slack bot that can be hosted on a free service to monitor your game servers and players in style. 😎",
"main": "src/server",
"scripts": {

View File

@@ -2,7 +2,6 @@ import { Client, GatewayIntentBits, TextChannel, Message, EmbedBuilder, APIEmbed
import { Low, JSONFile } from '@commonify/lowdb';
import { GameServer } from './game-server';
import hhmmss from './lib/hhmmss';
import getConnectUrl from './lib/connect-url';
import { DiscordConfig } from './watcher';
const DATA_PATH = process.env.DATA_PATH || './data/';
@@ -178,8 +177,8 @@ class ServerInfoMessage {
if (gs.info.game) fields.push({ name: 'Game', value: String(gs.info.game), inline: true});
if (gs.info.map) fields.push({ name: 'Map', value: String(gs.info.map), inline: true});
fields.push({ name: 'Players', value: gs.info.playersNum + '/' + gs.info.playersMax, inline: true});
fields.push({ name: 'Connect', value: getConnectUrl(gs.info.connect)});
fields.push({ name: 'Players', value: String(gs.info.playersNum + '/' + gs.info.playersMax), inline: true});
fields.push({ name: 'Address', value: String(gs.info.connect)});
if (showPlayersList && gs.info?.players.length > 0) {
const pNames: string[] = [];

View File

@@ -1,7 +0,0 @@
export default function getConnectUrl(uri: string) {
if (uri.indexOf('//') === -1) {
return 'steam://connect/' + uri;
}
return uri;
}

View File

@@ -2,7 +2,6 @@ import { App, Block, KnownBlock, LogLevel, MrkdwnElement, PlainTextElement } fro
import { Low, JSONFile } from '@commonify/lowdb';
import { GameServer } from './game-server';
import hhmmss from './lib/hhmmss';
import getConnectUrl from './lib/connect-url';
import { SlackConfig } from './watcher';
const DATA_PATH = process.env.DATA_PATH || './data/';
@@ -185,16 +184,16 @@ class ServerInfoMessage {
});
}
text += '\r\nPlayers: ' + gs.info.playersNum;
text += '\r\nPlayers: ' + String(gs.info.playersNum);
fields2.push({
type: 'mrkdwn',
text: '*Players* \r\n' + String(gs.info.playersNum + '/' + gs.info.playersMax)
});
text += '\r\nConnect: ' + getConnectUrl(gs.info.connect);
text += '\r\nAddress: ' + String(gs.info.connect);
fields2.push({
type: 'mrkdwn',
text: '*Connect* \r\n' + getConnectUrl(gs.info.connect)
text: '*Address* \r\n' + String(gs.info.connect)
});
if (fields2.length > 0) {

View File

@@ -2,7 +2,6 @@ import { Bot } from 'grammy';
import { Low, JSONFile } from '@commonify/lowdb';
import { GameServer } from './game-server';
import hhmmss from './lib/hhmmss';
import getConnectUrl from './lib/connect-url';
import { TelegramConfig } from './watcher';
const DATA_PATH = process.env.DATA_PATH || './data/';
@@ -138,7 +137,7 @@ class ServerInfoMessage {
infoText = [
this.escapeMarkdown(gs.niceName),
this.escapeMarkdown(gs.info.game) + ' / ' + this.escapeMarkdown(gs.info.map),
getConnectUrl(gs.info.connect),
this.escapeMarkdown(gs.info.connect),
'Players ' + gs.info.playersNum + '/' + gs.info.playersMax
].join('\n');