chipmunkbot3/plugins/blacklist.js

32 lines
769 B
JavaScript
Raw Permalink Normal View History

2024-02-11 21:23:41 -05:00
const fs = require('fs')
const path = require('path')
const filepath = path.resolve('persistent', 'blacklist.json')
// load the blacklist
let blacklist = []
try {
blacklist = require(filepath)
} catch (e) {
console.log('An error occured while loading the blacklist.')
}
// save it every 5 minutes
setInterval(() => {
fs.writeFileSync(filepath, JSON.stringify(blacklist, null, 2))
}, 5 * 6000)
// expose the blacklist and make the bot uuid ban blacklisted players
2024-02-29 20:39:21 -05:00
function inject (bot) {
bot.blacklist = blacklist
2024-02-11 21:23:41 -05:00
2024-02-29 20:39:21 -05:00
bot.on('player_added', player => {
for (const [pattern, flags] of blacklist) {
const regex = new RegExp(pattern, flags)
if (regex.test(player.username)) bot.exploits.uuidBan(player.uuid)
2024-02-11 21:23:41 -05:00
}
})
}
2024-02-29 20:39:21 -05:00
module.exports = inject