This repository contains the code for the @rsgMLB Twitter Bot, an automated system that posts interesting baseball statistics and facts. The bot is designed to run as an AWS Lambda function, periodically fetching data from Baseball-Reference.com and posting updates to Twitter.
- Scrapes player data from Baseball-Reference.com
- Parses HTML to extract relevant statistics
- Supports both position players and pitchers
- Generates engaging tweets based on player statistics
- Runs serverless on AWS Lambda
- TypeScript
- Node.js
- AWS Lambda
- Twitter API (via twitter-api-v2)
- Cheerio for HTML parsing
- Axios for HTTP requests
- Jest for testing
src/
: Contains the source TypeScript fileshandler.ts
: Main Lambda function handlerparsePlayer.ts
: Logic for parsing player data from HTMLparsePlayer.test.ts
: Unit tests for the parsing logiclocal.ts
: Script for running the bot locally
dist/
: Compiled JavaScript filessample_data/
: HTML samples for testing
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables (Twitter API keys, AWS credentials)
- Build the project:
npm run build
- Deploy to AWS Lambda (refer to AWS documentation for deployment steps)
- Run tests:
npm test
- Watch tests:
npm run test:watch
- Start locally:
npm start