A Python bot that automatically fetches NBA game schedules from ESPN API and sends formatted messages to a Telegram chat.
- Fetches daily NBA game schedule from ESPN API
- Converts game times to Arizona time (MST/MDT)
- Sends beautifully formatted messages to Telegram
- Easy to schedule with cron or Task Scheduler
- Python 3.10 or newer
- Internet connection
- Telegram Bot Token (already configured)
- Telegram Chat ID (your chat ID or channel ID)
# Navigate to the project directory
cd nba-schedule-bot
# Install dependencies
pip install -r requirements.txtFor Personal Chat:
- Search for @userinfobot on Telegram
- Start a conversation - it will show your Chat ID
For Group/Channel:
- Add your bot to the group/channel as admin
- Send a message in the group/channel
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - Find the
chat.idin the response
Option A: Environment Variable (Recommended)
export TELEGRAM_CHAT_ID="your_chat_id_here"Option B: Edit Script Directly
Edit nba_schedule_bot.py and replace:
CHAT_ID = "YOUR_CHAT_ID"with your actual Chat ID
python3 nba_schedule_bot.pyYou should receive a message in your Telegram chat with today's NBA games.
# Open crontab editor
crontab -e
# Add this line to run daily at 9:00 AM Arizona time
# Note: Adjust path to your script location
0 9 * * * /usr/bin/python3 /Users/joey/nba-schedule-bot/nba_schedule_bot.py >> /Users/joey/nba-schedule-bot/bot.log 2>&1Note: Cron runs in system timezone. To run at 9:00 AM Arizona time regardless of server timezone, you may need to adjust the cron time based on your server's timezone.
- Open Task Scheduler
- Create Basic Task
- Set trigger: Daily at 09:00 AM
- Set action: Start a program
- Program:
python(or full path topython.exe) - Arguments:
"C:\path\to\nba_schedule_bot.py" - Start in:
C:\path\to\
- Program:
For more control, you can use the provided scheduler:
pip install schedule
python3 scheduler.pyThis will run the bot continuously and execute it daily at 9:00 AM.
🏀 NBA Games Today (Nov 1, 2025):
Sacramento Kings @ Milwaukee Bucks — 2:00 PM MST
Minnesota Timberwolves @ Charlotte Hornets — 3:00 PM MST
Orlando Magic @ Washington Wizards — 4:00 PM MST
Golden State Warriors @ Indiana Pacers — 4:00 PM MST
Houston Rockets @ Boston Celtics — 5:00 PM MST
Dallas Mavericks @ Detroit Pistons — 7:00 PM MST
- Verify CHAT_ID is correct
- Make sure you've started a conversation with your bot (for personal chats)
- Check that your bot has permission to send messages (for groups/channels)
- The script uses
America/Phoenixtimezone (MST/MDT) - To change timezone, modify the
TIMEZONEvariable in the script
- Check your internet connection
- ESPN API might be temporarily unavailable
- Verify the API URL is accessible
- Add estimated halftimes (+45 min & +60 min)
- Include live scores if games are ongoing
- Add Telegram commands like
/today,/tomorrow,/halftimes - Log results to a file or database
- Add error notifications
Free to use and modify as needed.