This commit is contained in:
smsteel 2019-02-11 01:53:45 +03:00
parent 75a0b40af5
commit 6aed4a96d7
3 changed files with 16 additions and 3 deletions

10
bot.js
View File

@ -9,6 +9,7 @@ import {
} from './types' } from './types'
import { currentTime } from './utility' import { currentTime } from './utility'
import { getEntityDeathMessage, getEntityName } from './ru' import { getEntityDeathMessage, getEntityName } from './ru'
import stringTable from 'string-table'
const bot = new Telegraf('643297173:AAGuqfZx3GhiiARwvY7AtWTTFw1T-2FiwCM') const bot = new Telegraf('643297173:AAGuqfZx3GhiiARwvY7AtWTTFw1T-2FiwCM')
const markdown = TelegrafExtra.markdown() const markdown = TelegrafExtra.markdown()
@ -18,9 +19,12 @@ bot.command(
'players', 'players',
({ replyWithMarkdown }) => getPlayersData() ({ replyWithMarkdown }) => getPlayersData()
.then(getPlayersData => replyWithMarkdown( .then(getPlayersData => replyWithMarkdown(
getPlayersData stringTable.create(getPlayersData
.map(({ displayName, level, online }) => `👤 *${displayName}* уровень ${level} ${online ? '✅ *онлайн*' : '❔ оффлайн'}`) .map(({ displayName, level, online }) => ({
.join('\n') 'имя': `👤 *${displayName}*`,
'уровень': level,
'статус': `${online ? '✅ *онлайн*' : '❔ оффлайн'}`
})))
)) ))
) )
bot.launch() bot.launch()

8
package-lock.json generated
View File

@ -4818,6 +4818,14 @@
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz",
"integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew=="
}, },
"string-table": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/string-table/-/string-table-0.1.5.tgz",
"integrity": "sha1-h9rXSfsFTvUBY3u6OaFo8VheTmg=",
"requires": {
"colors": "1.3.3"
}
},
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",

View File

@ -23,6 +23,7 @@
"@babel/preset-env": "^7.3.1", "@babel/preset-env": "^7.3.1",
"express": "^4.16.4", "express": "^4.16.4",
"sqlite3": "^4.0.6", "sqlite3": "^4.0.6",
"string-table": "^0.1.5",
"telegraf": "^3.27.1" "telegraf": "^3.27.1"
} }
} }