telegram: show graph even if player count is 0 atm.

This commit is contained in:
Smith
2022-04-09 20:40:18 +02:00
parent f57dc6d596
commit dff1cd65d7
5 changed files with 27 additions and 6 deletions

18
config/mta.config.json Normal file
View 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
View File

@@ -213,7 +213,7 @@ class ServerHistory {
}
return this._stats;
}
statsChart(playersMax) {
statsChart(playersMax = -1) {
const stats = this.stats();
const e = encodeURIComponent;
const avg = [];

View File

@@ -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' });

View File

@@ -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;

View File

@@ -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 {