[HRT-79] Alertes Telegram configurables (Premium) #11

Merged
admin merged 1 commits from feature/HRT-79-telegram-alerts into master 2026-04-29 16:48:47 +02:00
Owner

[HRT-79] Alertes Telegram configurables Premium/Pro

Résumé

Implémentation complète du service d'alertes Telegram pré-course pour les utilisateurs Premium/Pro.

Fichiers

Nouveaux fichiers

  • telegram_alerts.py — service envoi Bot API, send_pre_race_alerts(), build_race_alert(), gestion gracieuse TELEGRAM_BOT_TOKEN absent (warn + return early)
  • api_v1/routes/user.py — blueprint user_bpGET/POST /api/v1/user/telegram-config — protégé @jwt_required_middleware + @plan_required("premium", "pro")

Fichiers modifiés

  • auth_db.pymigrate_telegram_columns() idempotente (ALTER TABLE + try/except OperationalError) — colonnes: telegram_chat_id, alert_value_bets, alert_top1, alert_quinte_only
  • api_v1/__init__.py — import + register user_bp (9e blueprint)
  • turf_scheduler.pyrun_telegram_alerts() + schedule_dynamic_telegram_alerts() 30min avant course — try/except Exception + fallback logger comme demandé CTO

Points CTO adressés

  1. TELEGRAM_BOT_TOKEN absent → log warning + return early (pas de crash)
  2. schedule_dynamic_telegram_alerts() → bloc try/except Exception + logger comme schedule_dynamic_results()
  3. Backups créés: auth_db.py.backup_20260429_163811, turf_scheduler.py.backup_20260429_163811

Tests recommandés avant merge

  • python3 -c "import telegram_alerts; print(telegram_alerts.send_pre_race_alerts())" sans TELEGRAM_BOT_TOKEN → doit logger warning, retourner {sent:0}
  • python3 auth_db.py → vérifier migration idempotente
  • curl -H "Authorization: Bearer <jwt_premium>" /api/v1/user/telegram-config
## [HRT-79] Alertes Telegram configurables Premium/Pro ### Résumé Implémentation complète du service d'alertes Telegram pré-course pour les utilisateurs Premium/Pro. ### Fichiers **Nouveaux fichiers** - `telegram_alerts.py` — service envoi Bot API, `send_pre_race_alerts()`, `build_race_alert()`, gestion gracieuse `TELEGRAM_BOT_TOKEN` absent (warn + return early) - `api_v1/routes/user.py` — blueprint `user_bp` — `GET/POST /api/v1/user/telegram-config` — protégé `@jwt_required_middleware` + `@plan_required("premium", "pro")` **Fichiers modifiés** - `auth_db.py` — `migrate_telegram_columns()` idempotente (ALTER TABLE + try/except OperationalError) — colonnes: `telegram_chat_id`, `alert_value_bets`, `alert_top1`, `alert_quinte_only` - `api_v1/__init__.py` — import + register `user_bp` (9e blueprint) - `turf_scheduler.py` — `run_telegram_alerts()` + `schedule_dynamic_telegram_alerts()` 30min avant course — try/except Exception + fallback logger comme demandé CTO ### Points CTO adressés 1. `TELEGRAM_BOT_TOKEN` absent → log warning + return early (pas de crash) 2. `schedule_dynamic_telegram_alerts()` → bloc try/except Exception + logger comme `schedule_dynamic_results()` 3. Backups créés: `auth_db.py.backup_20260429_163811`, `turf_scheduler.py.backup_20260429_163811` ### Tests recommandés avant merge - `python3 -c "import telegram_alerts; print(telegram_alerts.send_pre_race_alerts())"` sans TELEGRAM_BOT_TOKEN → doit logger warning, retourner {sent:0} - `python3 auth_db.py` → vérifier migration idempotente - `curl -H "Authorization: Bearer <jwt_premium>" /api/v1/user/telegram-config`
admin self-assigned this 2026-04-29 16:43:08 +02:00
admin added 1 commit 2026-04-29 16:43:09 +02:00
- telegram_alerts.py: service envoi alertes via Bot API (send_pre_race_alerts,
  build_race_alert, send_telegram_message) — gestion gracieuse TELEGRAM_BOT_TOKEN absent
- auth_db.py: migrate_telegram_columns() idempotente (ALTER TABLE + try/except OperationalError)
  colonnes: telegram_chat_id, alert_value_bets, alert_top1, alert_quinte_only
- api_v1/routes/user.py: blueprint user_bp GET/POST /api/v1/user/telegram-config
  protégé @jwt_required_middleware + @plan_required('premium','pro')
- api_v1/__init__.py: import + register user_bp
- turf_scheduler.py: run_telegram_alerts() + schedule_dynamic_telegram_alerts()
  planifiées 30min avant course (même pattern que schedule_dynamic_scoring)
  avec try/except Exception + fallback logger

Co-Authored-By: Paperclip <noreply@paperclip.ing>
admin merged commit b7ed82418f into master 2026-04-29 16:48:47 +02:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/turf_saas#11