chipmunkbot3/plugins/mail.js

29 lines
655 B
JavaScript
Raw Normal View History

2024-02-11 21:23:41 -05:00
const fs = require('fs')
const path = require('path')
const filepath = path.resolve('persistent', 'mail.json')
// load the blacklist
let mail = {}
try {
mail = require(filepath)
} catch (e) {
console.log('An error occured while loading the mail.')
}
// save it every 5 minutes
setInterval(() => {
2024-02-16 22:59:09 -05:00
fs.writeFileSync(filepath, JSON.stringify(mail))
2024-02-11 21:23:41 -05:00
}, 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.bot = inject