diff --git a/.gitignore b/.gitignore index 2d34204..657efbb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ config.json blacklist.json blacklist.log memories.json +demo.js # ---> Node # Logs diff --git a/bot.js b/bot.js index c374098..9159c26 100644 --- a/bot.js +++ b/bot.js @@ -295,6 +295,35 @@ const runLogic = (client, from, to, message) => { if (check) { useCheatCode(client, from, to, cheatCode); } + } else if (message.startsWith("!hmmscoreboard")) { + const check = checkBlacklist(client, from, to, ""); + const size = 3; + const compare = (a, b) => { + if (a.score < b.score) { + return -1; + } else if (a.score > b.score) { + return 1; + } + return 0; + } + if (check) { + const hmmscores = client.brain.memories.hmmscores || {}; + const scores = []; + Object.keys(hmmscores).forEach((user) => { + const hmmscore = hmmscores[user]; + scores.push({ + user: user, + score: hmmscore + }); + }); + const leaderBoard = scores.sort(compare).reverse().splice(0, size); + const header = "Hmm Score Leaderboard:"; + const entries = []; + leaderBoard.forEach((entry) => { + entries.push(`${entry.user} ${entry.score}`); + }); + client.say(to, `${header} ${entries.join(" | ")}`); + } } else if ( message.startsWith("!summon ") || message.startsWith("!hmmscore ") ||