From 2266cd47898da89acf58b5ca5e005087ba0f5937 Mon Sep 17 00:00:00 2001 From: wgroeneveld Date: Thu, 1 Apr 2021 19:53:23 +0200 Subject: [PATCH] added readme for existing buddies --- README.md | 5 +++++ src/buddies/mobygames/collector.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2dc7474..1af8130 100644 --- a/README.md +++ b/README.md @@ -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 }`. diff --git a/src/buddies/mobygames/collector.js b/src/buddies/mobygames/collector.js index 77fd6bb..9e9c810 100644 --- a/src/buddies/mobygames/collector.js +++ b/src/buddies/mobygames/collector.js @@ -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)