A bot that tweets random Pokémon facts.
Set up:
pip install -r requirements.txt.- Export environment variables.
python3 {filename}to run.
Environment variables can be fetched from AWS. They should be added to this repo
in a file called .env.local:
MASTODON_CLIENT_KEY=...
MASTODON_CLIENT_SECRET=...
MASTODON_ACCESS_TOKEN=...
ANTHROPIC_API_KEY=...To deploy this app, run:
sh deploy.shanthropic and Pillow ship compiled wheels, so deploy.sh fetches them for
Lambda's platform rather than for the machine running the script. PY_VERSION
and PLATFORM in that script must match the deployed function — check with:
aws lambda get-function-configuration --function-name pokemonFacts --region us-east-1This script fetches a card from a Pokémon API and posts it.
The sprite is chosen at random from every variant PokeAPI offers, so a third of posts are back views and 42% are Shiny recolors. The alt text therefore states what the image actually is ("seen from behind, in its rare Shiny coloring, shown as a pixel-art sprite from Pokémon Gold") and then describes the sprite that is being posted, written in the voice of a Pokédex entry.
The description comes from Claude (claude-haiku-4-5) looking at the image, so
it reflects the colors in that particular sprite rather than the species' usual
colors. If that call fails, the bot falls back to a description built from
PokeAPI's own genus, color and shape fields, hedged with "usually" because
those describe the species and not the picture.
Small sprites are as little as 32x32, which Mastodon renders as a blurry thumbnail, so pixel art is scaled up by a whole-number factor with nearest-neighbor sampling before posting. Animated sprites keep their frames. Artwork that is already large and smooth, such as official artwork and Pokémon HOME renders, is left alone.
The copy sent to Claude is scaled larger than the copy that gets posted. On an 80x80 sprite a leg is two pixels wide, and at 384px small details came back wrong; at 768px they did not. That setting mattered considerably more than which model was used.