feat(alerts): prefijo 'OPENSHORTS ✂️ -' en todos los mensajes de Telegram
El chat de Telegram es compartido con Upload-Post y otros productos, así que cada mensaje de OpenShorts se marca con el nombre para distinguirlos de un vistazo. Aplicado en send_telegram, cubre todas las alertas (pagos, subs, churn, clips).
This commit is contained in:
parent
2efbeb2828
commit
7d6c232165
1 changed files with 7 additions and 1 deletions
|
|
@ -48,6 +48,11 @@ def _cooldown_ok(kind: str) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
# Prefix on every OpenShorts Telegram message. The chat is shared with other
|
||||||
|
# products (Upload-Post, …), so this tags which one each alert is from.
|
||||||
|
TELEGRAM_PREFIX = "OPENSHORTS ✂️ - "
|
||||||
|
|
||||||
|
|
||||||
async def send_telegram(text: str):
|
async def send_telegram(text: str):
|
||||||
"""Push a plain-text message to the admin's Telegram chat. No-op if unset.
|
"""Push a plain-text message to the admin's Telegram chat. No-op if unset.
|
||||||
|
|
||||||
|
|
@ -58,7 +63,8 @@ async def send_telegram(text: str):
|
||||||
try:
|
try:
|
||||||
import httpx
|
import httpx
|
||||||
url = f"https://api.telegram.org/bot{settings.telegram_bot_token}/sendMessage"
|
url = f"https://api.telegram.org/bot{settings.telegram_bot_token}/sendMessage"
|
||||||
payload = {"chat_id": settings.telegram_chat_id, "text": text,
|
payload = {"chat_id": settings.telegram_chat_id,
|
||||||
|
"text": TELEGRAM_PREFIX + text,
|
||||||
"disable_web_page_preview": True}
|
"disable_web_page_preview": True}
|
||||||
async with httpx.AsyncClient(timeout=10) as client:
|
async with httpx.AsyncClient(timeout=10) as client:
|
||||||
await client.post(url, json=payload)
|
await client.post(url, json=payload)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue