A Telegram bot that helps you keep your daily LeetCode practice streak alive. It tracks linked members' daily submissions, posts status updates, and automatically resets streaks if a day is missed.
- Individual Streak Tracking: Tracks streaks for every linked user.
- Daily Resets: Automatically checks streaks at the end of the day (00:00 SGT) and resets them if no submission is found.
- Live Status: Check who has solved a problem today with
/statusand refresh the data instantly. - Supabase Integration: fast and persistent storage using Supabase (PostgreSQL).
- Handy Links: Provides links to solved problems and difficulty indicators.
- Python,
python-telegram-bot - Supabase (PostgreSQL)
/start— Quick help and usage overview./link <leetcode_username>— Link your Telegram user to a LeetCode username./status— Show today’s completion status for all linked members. Includes a "Refresh" button to update data.
- Start the bot:
/start - Link your LeetCode account:
/link <leetcode_username> - Check status:
The bot will show who has completed a problem today and their current streak.
/status
-
Prerequisites: Python 3.10+ and
pip. -
Install dependencies:
pip install -r requirements.txt
-
Supabase Setup:
- Create a Supabase project.
- Create a
playerstable with the following columns:tele_id(int8, Primary Key)tele_username(text)lc_username(text)streak(int8, default 0)last_streak_upgrade(timestamptz, nullable)
-
Environment Variables: Create a
.envfile in the project root:BOT_TOKEN=your-telegram-bot-token NODE_ENV=development TIMEZONE=Asia/Singapore # Supabase Credentials SUPABASE_URL=your-supabase-project-url SUPABASE_KEY=your-supabase-anon-key # Base URLs for LeetCode API API_BASE_DEV=https://your-api.dev.example.com API_BASE_PROD=https://your-api.prod.example.com
-
Start the bot:
python bot.py
- Persistence: Uses Supabase to store player data and streaks.
- Global Tracking: Currently, the bot tracks all linked users globally. The
/statuscommand will show every user registered in the database. - Scheduling:
- A daily job runs at 00:00 SGT to check for missed days.
- If a user hasn't solved a problem by then, their streak is reset to 0.
- Timezone: Configurable via
TIMEZONE(defaults toAsia/Singapore).
The bot fetches data from a LeetCode-compatible API:
GET {API_BASE}/{username}/acSubmission?limit=20GET {API_BASE}/select?titleSlug=<slug>
- Virtualenv:
python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt
- Logging: Controlled via
logging.basicConfiginbot.py.
MIT