table test

This commit is contained in:
smsteel 2019-02-11 09:10:36 +03:00
parent 6eacd8bcd2
commit b6e46ed0a9
2 changed files with 29 additions and 7 deletions

35
bot.js
View File

@ -9,7 +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' import table from '1table'
const bot = new Telegraf('643297173:AAGuqfZx3GhiiARwvY7AtWTTFw1T-2FiwCM') const bot = new Telegraf('643297173:AAGuqfZx3GhiiARwvY7AtWTTFw1T-2FiwCM')
const markdown = TelegrafExtra.markdown() const markdown = TelegrafExtra.markdown()
@ -19,12 +19,33 @@ bot.command(
'players', 'players',
({ replyWithMarkdown }) => getPlayersData() ({ replyWithMarkdown }) => getPlayersData()
.then(getPlayersData => replyWithMarkdown( .then(getPlayersData => replyWithMarkdown(
stringTable.create(getPlayersData table(
.map(({ displayName, level, online }) => ({ getPlayersData
'имя': `👤 *${displayName}*`, .map(({ displayName, level, online }) => ([
'уровень': level, `👤 *${displayName}*`,
'статус': `${online ? '✅ *онлайн*' : '❔ оффлайн'}` level,
}))) `${online ? '✅ *онлайн*' : '❔ оффлайн'}`
])),
{
border: {
topBody: ``,
topJoin: ``,
topLeft: ``,
topRight: ``,
bottomBody: ``,
bottomJoin: ``,
bottomLeft: ``,
bottomRight: ``,
bodyLeft: ``,
bodyRight: ``,
bodyJoin: `|`,
joinBody: `-`,
joinLeft: ``,
joinRight: ``,
joinJoin: `|`
}
}
)
)) ))
) )
bot.launch() bot.launch()

View File

@ -24,6 +24,7 @@
"express": "^4.16.4", "express": "^4.16.4",
"sqlite3": "^4.0.6", "sqlite3": "^4.0.6",
"string-table": "^0.1.5", "string-table": "^0.1.5",
"table": "^5.2.3",
"telegraf": "^3.27.1" "telegraf": "^3.27.1"
} }
} }