31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
import logging
|
|
import aiohttp
|
|
import asyncio
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
# Токен личного бота Майи (@ktybdsqbot) и ID Александра
|
|
MAYA_BOT_TOKEN = "8065539545:AAECBnyjinUVVGv3vhtoWZ99tUmnT9sze-k"
|
|
ALEXANDER_CHAT_ID = 197957361
|
|
|
|
async def send_domovoy_alert(title: str, message: str, level: str = "INFO"):
|
|
"""Отправляет служебный алерт от Домового напрямую в личный чат Майи Александру."""
|
|
emoji = "🔔" if level == "INFO" else "⚠️" if level == "WARNING" else "🚨"
|
|
formatted_text = f"{emoji} <b>[Домовой МКД] {title}</b>\n\n{message}"
|
|
|
|
url = f"https://api.telegram.org/bot{MAYA_BOT_TOKEN}/sendMessage"
|
|
payload = {
|
|
"chat_id": ALEXANDER_CHAT_ID,
|
|
"text": formatted_text,
|
|
"parse_mode": "HTML"
|
|
}
|
|
|
|
try:
|
|
async with aiohttp.ClientSession() as session:
|
|
async with session.post(url, json=payload, timeout=10) as resp:
|
|
if resp.status == 200:
|
|
logger.info(f"✅ Alert forwarded to Maya bot: {title}")
|
|
else:
|
|
logger.warning(f"Failed to forward alert: {resp.status}")
|
|
except Exception as e:
|
|
logger.error(f"Error sending alert to Maya: {e}")
|