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

View File

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