forked from Rockachopa/Timmy-time-dashboard
feat: add Telegram bot integration
Bridges Telegram messages to Timmy via python-telegram-bot (optional dependency). The bot token can be supplied through the TELEGRAM_TOKEN env var or at runtime via the new POST /telegram/setup dashboard endpoint, which (re)starts the bot without a restart. Changes: - src/telegram_bot/bot.py — TelegramBot singleton: token persistence (telegram_state.json), lifecycle (start/stop), /start command and message handler that forwards to Timmy - src/dashboard/routes/telegram.py — /telegram/setup and /telegram/status FastAPI routes - src/dashboard/app.py — register telegram router; auto-start/stop bot in lifespan hook - src/config.py — TELEGRAM_TOKEN setting (pydantic-settings) - pyproject.toml — [telegram] optional extra (python-telegram-bot>=21), telegram_bot wheel include - .env.example — TELEGRAM_TOKEN section - .gitignore — exclude telegram_state.json (contains token) - tests/conftest.py — stub telegram/telegram.ext for offline test runs - tests/test_telegram_bot.py — 16 tests covering token helpers, lifecycle, and all dashboard routes (370 total, all passing) https://claude.ai/code/session_01CNBm3ZLobtx3Z1YogHq8ZS
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,6 +21,9 @@ env/
|
||||
# SQLite memory — never commit agent memory
|
||||
*.db
|
||||
|
||||
# Telegram bot state (contains bot token)
|
||||
telegram_state.json
|
||||
|
||||
# Testing
|
||||
.pytest_cache/
|
||||
.coverage
|
||||
|
||||
Reference in New Issue
Block a user