chipmunkbot-archive/plugins/mail.js
2023-06-26 23:04:54 -04:00

25 lines
No EOL
596 B
JavaScript

const fs = require('fs')
// load the blacklist
let mail = {}
try {
mail = require('./../persistent/mail.json')
} catch(e) {
console.log('An error occured while loading the mail.')
}
// save it every 5 minutes
setInterval(() => {
fs.writeFileSync('./persistent/mail.json', JSON.stringify(mail))
}, 5 * 6000)
// make the bot uuid ban blacklisted players
function inject(bot) {
bot.mail = mail
bot.sendMail = (sender, reciever, message) => {
if (!mail[reciever]) mail[reciever] = []
mail[reciever].push({ sender: sender, message, host: bot.host })
}
}
module.exports = inject