35 lines
1016 B
JavaScript
35 lines
1016 B
JavaScript
|
|
const { collect } = require('./collector')
|
|
const md5 = require('md5')
|
|
|
|
async function chat() {
|
|
/* format:
|
|
{
|
|
"href": "/wiki/Admiral",
|
|
"name": "Admiral",
|
|
"birthday": "January 27<sup>th</sup>\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(/\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
|
|
}
|