diff --git a/.env.example b/.env.example index bec2925..33f18b1 100644 --- a/.env.example +++ b/.env.example @@ -47,6 +47,14 @@ MATCHER_AUDIENCE=web,mobile # tipos de suscripción que generan notifs aquí (t MATCHER_POLL_MS=30000 # cada cuánto sondea activefires (Mongo 3.2, sin change streams) MATCHER_BATCH=2000 # máx fuegos por ciclo +# --- Telegram (fase 1c: envío de alertas por los bots) --- +# Añade 'telegram' a OWNED_CHANNELS y MATCHER_AUDIENCE para activarlo. +TELEGRAM_TOKEN_ES= # SECRETO: token del bot ES (extraer de flows_cred de node-red) +TELEGRAM_TOKEN_EN= # SECRETO: token del bot EN +TELEGRAM_SERVER= # host para el firelink (por defecto = host de ROOT_URL) +TELEGRAM_GLOBAL_PER_SEC=25 # límite global msg/s por bot (Telegram permite ~30) +TELEGRAM_PER_CHAT_MS=1000 # mínimo ms entre mensajes al mismo chat (~1 msg/s) + # --- Enlaces / mapas --- ROOT_URL=https://fuegos.comunes.org/ GMAPS_KEY= # Meteor.settings.gmaps.key diff --git a/README.md b/README.md index 9a1fcde..b4970cf 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,9 @@ sistema) + Redis local. En fase 3 pasa a Docker Compose. - [x] **1b**: matcher geoespacial (content i18n, geolib, `sealed` vía Iron — compatible con la web —, dedupe 500 m), ingesta por polling, modos `shadow`/`full`, comparador de shadow. Tests en verde. +- [x] **1c**: telegram-worker (texto + ubicación, firelink, rate limiting + global 25/s + 1/s por chat, 429/bloqueo, idempotencia). Tests en verde. + **Código migrado; sin tokens configurados → inerte.** - [ ] **1a full**: envío masivo FCM (~8176 users) — con el usuario, vigilando. - [ ] **1b**: rollout `shadow` ≥3 días → comparar → cutover node-red → `full`. -- [ ] **1c**: envío Telegram. +- [ ] **1c**: extraer tokens de bot → rollout `shadow`/canary → cutover node-red. diff --git a/docs/legacy-telegram.md b/docs/legacy-telegram.md new file mode 100644 index 0000000..bd09a9d --- /dev/null +++ b/docs/legacy-telegram.md @@ -0,0 +1,57 @@ +# Envío Telegram viejo (fase 1c — caracterización) + +> Fuente: `todos-contra-el-fuego/telegram-bot/flows.json` (nodos "calc distances", +> "send location", senders `telegram sender`), locales node-red. + +## Qué envía node-red por cada alerta de fuego a un chat suscrito + +**Dos mensajes** al `chatId` de la suscripción (subs `type: 'telegram'`): + +1. **Texto** (`type: "message"`, `parse_mode: "Markdown"`): + `content` + salto de línea + `firelink`. + - `content` = la misma cadena `kmnasa`/`kmvecinal` del matching + (ver `legacy-matching.md` §3; lleva `🔥` y el `км` cirílico). + - `firelink` (i18n): `[