const { collect } = require('./collector') const md5 = require('md5') async function chat(buddyConfig) { /* format: { "href": "/wiki/Admiral", "name": "Admiral", "birthday": "January 27th\n", "img": "https://static.wikia.nocookie.net/animalcrossing/images/5/52/NH-Admiral_poster.png/revision/latest?cb=20200522013249", "quotes": [ "Only quitters give up." ] } */ const animaldb = await collect() const possibleToots = animaldb.animals.map(record => { return record.quotes.map(quote => { const birthday = record.birthday .replace(/(.*)<\/sup>/g, "$1") .replace(/\n/g, "") return { "toot": `${record.name}: "${quote}"\n\n${birthday} is my birthday.\nhttps://animalcrossing.fandom.com${record.href}`, "attach": [ `data/ac/${md5(record.img)}.png` ], "attachDescription": `Screenshot of Animal Crossing villager ${record.name}` } }) }).flat() return possibleToots[Math.floor(Math.random() * possibleToots.length)] } module.exports = { chat }