kill count
This commit is contained in:
parent
94298202b8
commit
ac755538f7
31
bot.js
31
bot.js
@ -32,23 +32,22 @@ bot.command(
|
||||
)
|
||||
))
|
||||
)
|
||||
bot.command(
|
||||
'kills',
|
||||
({ replyWithMarkdown }) => getAllKills()
|
||||
bot.hears(
|
||||
/^\/kills (.*)$/,
|
||||
ctx => getAllKills(ctx.match[1])
|
||||
.then(allKills => {
|
||||
let groupedKills = [{}]
|
||||
let currentGroupId = 0
|
||||
allKills.forEach(kills => {
|
||||
if (groupedKills[currentGroupId].displayName && groupedKills[currentGroupId].displayName !== kills.displayName) {
|
||||
currentGroupId++
|
||||
}
|
||||
groupedKills[currentGroupId] = {
|
||||
displayName: kills.displayName,
|
||||
...groupedKills[currentGroupId],
|
||||
[kills.entityName]: kills.killCount
|
||||
}
|
||||
})
|
||||
replyWithMarkdown(formattedStringTable(groupedKills))
|
||||
if (!allKills) {
|
||||
ctx.reply('Не найдено')
|
||||
return
|
||||
}
|
||||
ctx.replyWithMarkdown(
|
||||
formattedStringTable(
|
||||
allKills.map(kills => ({
|
||||
'монстр': getEntityName(kills.entityName),
|
||||
'убийств': kills.killCount
|
||||
}))
|
||||
)
|
||||
)
|
||||
})
|
||||
)
|
||||
bot.launch()
|
||||
|
@ -93,7 +93,7 @@ export const getKillCount = (displayName, entityName) => get(
|
||||
'killCount',
|
||||
0
|
||||
)
|
||||
export const getAllKills = () => all('SELECT * FROM playerKills ORDER BY displayName ASC')
|
||||
export const getAllKills = displayName => all('SELECT * FROM playerKills WHERE displayName = ? ORDER BY displayName ASC', [ displayName ])
|
||||
|
||||
export const saveLevelUp = (displayName, levelUpCount) => run(
|
||||
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user