feat: Telegram теперь опциональный, как MAX
This commit is contained in:
+4
-2
@@ -22,8 +22,8 @@ MIKROTIK_PORT = int(os.getenv("MIKROTIK_PORT", "8728"))
|
||||
MIKROTIK_USER = os.environ["MIKROTIK_USER"]
|
||||
MIKROTIK_PASSWORD = os.environ["MIKROTIK_PASSWORD"]
|
||||
|
||||
TELEGRAM_BOT_TOKEN = os.environ["TELEGRAM_BOT_TOKEN"]
|
||||
TELEGRAM_CHAT_ID = os.environ["TELEGRAM_CHAT_ID"]
|
||||
TELEGRAM_BOT_TOKEN = os.getenv("TELEGRAM_BOT_TOKEN", "")
|
||||
TELEGRAM_CHAT_ID = os.getenv("TELEGRAM_CHAT_ID", "")
|
||||
TELEGRAM_API_URL = os.getenv("TELEGRAM_API_URL", "https://api.telegram.org")
|
||||
|
||||
# MAX (VK Teams) — опционально, если не заданы — уведомления не отправляются
|
||||
@@ -54,6 +54,8 @@ log = logging.getLogger(__name__)
|
||||
# Telegram
|
||||
# ──────────────────────────────────────────────
|
||||
async def send_telegram(message: str) -> None:
|
||||
if not TELEGRAM_BOT_TOKEN or not TELEGRAM_CHAT_ID:
|
||||
return
|
||||
url = f"{TELEGRAM_API_URL}/bot{TELEGRAM_BOT_TOKEN}/sendMessage"
|
||||
payload = {"chat_id": TELEGRAM_CHAT_ID, "text": message, "parse_mode": "HTML"}
|
||||
async with httpx.AsyncClient(timeout=10) as client:
|
||||
|
||||
Reference in New Issue
Block a user