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(
|
bot.hears(
|
||||||
'kills',
|
/^\/kills (.*)$/,
|
||||||
({ replyWithMarkdown }) => getAllKills()
|
ctx => getAllKills(ctx.match[1])
|
||||||
.then(allKills => {
|
.then(allKills => {
|
||||||
let groupedKills = [{}]
|
if (!allKills) {
|
||||||
let currentGroupId = 0
|
ctx.reply('Не найдено')
|
||||||
allKills.forEach(kills => {
|
return
|
||||||
if (groupedKills[currentGroupId].displayName && groupedKills[currentGroupId].displayName !== kills.displayName) {
|
}
|
||||||
currentGroupId++
|
ctx.replyWithMarkdown(
|
||||||
}
|
formattedStringTable(
|
||||||
groupedKills[currentGroupId] = {
|
allKills.map(kills => ({
|
||||||
displayName: kills.displayName,
|
'монстр': getEntityName(kills.entityName),
|
||||||
...groupedKills[currentGroupId],
|
'убийств': kills.killCount
|
||||||
[kills.entityName]: kills.killCount
|
}))
|
||||||
}
|
)
|
||||||
})
|
)
|
||||||
replyWithMarkdown(formattedStringTable(groupedKills))
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
bot.launch()
|
bot.launch()
|
||||||
|
@ -93,7 +93,7 @@ export const getKillCount = (displayName, entityName) => get(
|
|||||||
'killCount',
|
'killCount',
|
||||||
0
|
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(
|
export const saveLevelUp = (displayName, levelUpCount) => run(
|
||||||
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,
|
`INSERT OR REPLACE INTO levelUps (displayName, levelUpCount) VALUES (?, ?)`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user