mirror of
https://github.com/a-sync/game-server-watcher.git
synced 2026-07-23 14:13:35 -04:00
telegram: show graph even if player count is 0 atm.
This commit is contained in:
18
config/mta.config.json
Normal file
18
config/mta.config.json
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"host": "37.221.209.167",
|
||||
"port": 22013,
|
||||
"type": "mtasa",
|
||||
"appId": 0,
|
||||
"discord": {
|
||||
"channelIds": [
|
||||
"961281582809890816"
|
||||
]
|
||||
},
|
||||
"telegram": {
|
||||
"chatIds": [
|
||||
""
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
2
dist/game-server.js
vendored
2
dist/game-server.js
vendored
@@ -213,7 +213,7 @@ class ServerHistory {
|
||||
}
|
||||
return this._stats;
|
||||
}
|
||||
statsChart(playersMax) {
|
||||
statsChart(playersMax = -1) {
|
||||
const stats = this.stats();
|
||||
const e = encodeURIComponent;
|
||||
const avg = [];
|
||||
|
||||
5
dist/telegram-bot.js
vendored
5
dist/telegram-bot.js
vendored
@@ -112,8 +112,8 @@ class ServerInfoMessage {
|
||||
'`' + gs.info.connect + '`',
|
||||
'Players ' + gs.info.playersNum + '/' + gs.info.playersMax
|
||||
].join('\n');
|
||||
const chart = '[📊](' + gs.history.statsChart(gs.info.playersMax) + ')';
|
||||
if (gs.info.players.length > 0) {
|
||||
const chart = '[📊](' + gs.history.statsChart(gs.info.playersMax) + ')';
|
||||
const pnArr = [];
|
||||
for (const p of gs.info.players) {
|
||||
let playerLine = '';
|
||||
@@ -129,9 +129,10 @@ class ServerInfoMessage {
|
||||
pnArr.push(playerLine);
|
||||
}
|
||||
if (pnArr.length > 0) {
|
||||
infoText += '```\n' + pnArr.join('\n').slice(0, 4088 - infoText.length - chart.length) + '\n```' + chart;
|
||||
infoText += '```\n' + pnArr.join('\n').slice(0, 4088 - infoText.length - chart.length) + '\n```';
|
||||
}
|
||||
}
|
||||
infoText += chart;
|
||||
}
|
||||
try {
|
||||
await bot.api.editMessageText(this.chatId, this.messageId, infoText, { parse_mode: 'Markdown' });
|
||||
|
||||
@@ -279,7 +279,7 @@ class ServerHistory {
|
||||
return this._stats;
|
||||
}
|
||||
|
||||
statsChart(playersMax: number): string {
|
||||
statsChart(playersMax: number = -1): string {
|
||||
const stats = this.stats();
|
||||
const e = encodeURIComponent;
|
||||
|
||||
|
||||
@@ -136,8 +136,8 @@ class ServerInfoMessage {
|
||||
'Players ' + gs.info.playersNum + '/' + gs.info.playersMax
|
||||
].join('\n');
|
||||
|
||||
const chart = '[📊](' + gs.history.statsChart(gs.info.playersMax) + ')';
|
||||
if (gs.info.players.length > 0) {
|
||||
const chart = '[📊](' + gs.history.statsChart(gs.info.playersMax) + ')';
|
||||
const pnArr: string[] = [];
|
||||
for(const p of gs.info.players) {
|
||||
let playerLine = '';
|
||||
@@ -153,9 +153,11 @@ class ServerInfoMessage {
|
||||
pnArr.push(playerLine);
|
||||
}
|
||||
if (pnArr.length > 0) {
|
||||
infoText += '```\n' + pnArr.join('\n').slice(0, 4088 - infoText.length - chart.length) + '\n```' + chart;
|
||||
infoText += '```\n' + pnArr.join('\n').slice(0, 4088 - infoText.length - chart.length) + '\n```';
|
||||
}
|
||||
}
|
||||
|
||||
infoText += chart;
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user