added readme for existing buddies

This commit is contained in:
Wouter Groeneveld 2021-04-01 19:53:23 +02:00
parent 0c1228dab5
commit 2266cd4789
2 changed files with 7 additions and 2 deletions

View File

@ -12,6 +12,11 @@ Yay! **Working examples** say more than a 1000 words:
Execute through `yarn toot` or `yarn node src/chat.js`. It cycles through all configured "buddies" and toots a message accordingly. Use your favorite `crontab` timestamp to fire off toots automatically.
### Packaged buddies
1. **animalcrossing**: collect data from https://animalcrossing.fandom.com/wiki/ and randomly toot about a villager, including a link to the fandom and the birthday. Uses dirty scraping, no rate limit hit yet...
2. **mobygames**: collect data through the moby games API so you'll need an API key: https://www.mobygames.com/info/api - the API is rate-limited at one call per second and 360 per hour. The above working example posts a random Game Boy game with two screenshots collected via the API. It's generic, so just configure `platform` in the config file (10 is GB).
### Creating a new buddy
Create a directory in `src/buddies/` and add it to `config.js` using the same name. Each buddy should have a `buddy.js` with one exposed method called `chat`, which gets executed with a config parameter. Look at the examples for more information. End the file with something like `module.exports = { chat }`.

View File

@ -52,7 +52,7 @@ async function collectScreenshotsFor(game, buddyConfig) {
// for the gameboy: 10, 688 - see https://www.mobygames.com/browse/games/gameboy/list-games/
async function collect(buddyConfig) {
const { platform, totalAmountOfGamesForPlatform, mobyGamesToken } = buddyConfig
const { platform, totalAmountOfGames = 600, mobyGamesToken } = buddyConfig
const overviewFile = `data/mobygames/games_${platform}.json`
if(existsSync(overviewFile)) {
@ -63,7 +63,7 @@ async function collect(buddyConfig) {
console.log(' -- mobygames: no overview json file found for platform, fetching...')
const allGames = []
for(let offset = 0; offset < totalAmountOfGamesForPlatform; offset += 100) {
for(let offset = 0; offset < totalAmountOfGames; offset += 100) {
console.log(` -- mobygames: fetching platform ${platform} offset ${offset}...`)
const result = await axios.get(`${endpoint}/games?platform=${platform}&api_key=${mobyGamesToken}&offset=${offset}`)
allGames.push(result.data.games)