Fase 1c: canal Telegram (telegram-worker) — codigo migrado, inerte
Envio de alertas Telegram desde el servicio (docs/legacy-telegram.md): por alerta, texto Markdown (content + firelink i18n) + ubicacion, como node-red. - types: canal 'telegram', notif.type 'telegram', campo telegramNotified - telegram/message.ts: buildTelegramMessages (firelink es/en/gl + location) - telegram/client.ts: cliente Bot API (fetch), interpretResponse (429 retry_after, 403 blocked) - telegram/rate.ts: throttle por chat (1 msg/s) + computeWaitMs puro - handlers.processTelegramJob: idempotencia (notification_sends canal telegram), modos dry-run/shadow/canary/full, throttle, 429->retry, bloqueo->sub inactiva - poller/queue/index: canal telegram integrado; worker con rate limiter global BullMQ (25/s por bot); cliente por idioma (es/gl->ES, en->EN) - config: bloque telegram (tokens es/en, server, globalPerSec, perChatMinMs) 85 tests en verde, typecheck y build OK. Sin TELEGRAM_TOKEN_* configurados el worker no se activa (todo inerte). Falta: extraer tokens de bot de flows_cred + rollout con el usuario. Los flujos conversacionales de los bots siguen en node-red.
This commit is contained in:
parent
a1ed206985
commit
d1fc6798dc
14 changed files with 479 additions and 14 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue