Инициализация публичного репозитория

This commit is contained in:
Dmitry
2026-04-24 20:30:33 +03:00
commit 0c6e1591d6
15 changed files with 1082 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import logging
from typing import Optional
import requests
class Notifier:
def __init__(self, token: str):
self.token = token
self.api_url = f"https://api.telegram.org/bot{token}"
self.logger = logging.getLogger(__name__)
def send_message(self, user_id: int, text: str) -> Optional[dict]:
try:
url = f"{self.api_url}/sendMessage"
payload = {
"chat_id": user_id,
"text": text,
"parse_mode": "HTML",
"disable_web_page_preview": True,
}
response = requests.post(url, json=payload, timeout=10)
response.raise_for_status()
return response.json()
except requests.RequestException as e:
self.logger.error(f"Failed to send message to {user_id}: {e}")
return None