from telegram import Bot from django.core.mail import send_mail async def send_telegram_notification(user, message): """Отправка уведомления через Telegram.""" if user.chat_id: try: bot = Bot(token="ВАШ_ТОКЕН") await bot.send_message(chat_id=user.chat_id, text=message) print(f"Telegram-уведомление отправлено пользователю {user.chat_id}: {message}") except Exception as e: print(f"Ошибка отправки Telegram-уведомления пользователю {user.chat_id}: {e}") def send_email_notification(user, message): """Отправка уведомления через Email.""" if user.email: try: send_mail( subject="Уведомление от системы", message=message, from_email="noreply@yourdomain.com", recipient_list=[user.email], fail_silently=False, ) print(f"Email-уведомление отправлено на {user.email}: {message}") except Exception as e: print(f"Ошибка отправки Email-уведомления пользователю {user.email}: {e}")