• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
project logo

gberg

cal-hits-bot

posts to bsky when Cal Raleigh gets a hit
Public
Like
cal-hits-bot
Home
Code
2
README.md
C
cal-hits-bot.js
Environment variables
2
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v60
View latest version
README.md

Cal Hits Bot

A Bluesky bot that posts whenever Seattle Mariners catcher Cal Raleigh gets a hit during a game.

How it works

The bot runs as a Val.town scheduled function every 5–10 minutes. It:

  1. Checks the MLB Stats API for a live or completed Mariners game
  2. Reads Cal Raleigh's batting stats from the boxscore
  3. Posts to Bluesky if a new hit or home run has occurred since the last check
  4. Persists hit state in Val.town blob storage to avoid duplicate posts

Home runs get special treatment — the bot fetches the season HR count and posts with extra flair.

Stack

  • Runtime: Val.town (serverless, cron-scheduled)
  • Bluesky: @atproto/api
  • Data: MLB Stats API (free, public, no auth required)
  • State: Val.town blob storage

Deploy your own

1. Set up Bluesky

Create an App Password in your Bluesky account settings (Settings → Privacy and Security → App Passwords). Do not use your main account password.

2. Deploy to Val.town

  1. Create a new Val at val.town
  2. Paste in the contents of cal-hits-bot.js
  3. Add environment variables:
    • BLUESKY_HANDLE — your Bluesky handle (e.g. yourbot.bsky.social)
    • BLUESKY_PASSWORD — the App Password you created
  4. Set the Val type to Cron with schedule */5 * * * * (or whatever)

That's it. Val.town handles execution, logging, and storage.

Local testing

npm install BLUESKY_HANDLE=your.handle.bsky.social BLUESKY_PASSWORD=your_app_password node cal-hits-bot.js

Adapting for another player

Change the player ID constant at the top of cal-hits-bot.js. You can look up any player's ID from the MLB Stats API:

https://statsapi.mlb.com/api/v1/people/search?names=FirstName+LastName

You'll also want to update the team ID used for schedule lookups and the hashtags in the post template.

License

MIT

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
AboutAlternativesPricingBlogNewsletterCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.