domovoy_bot/web/templates/broadcast.html
Admin da010eccbf 🌐 ВЕБ-АДМИНКА: РАССЫЛКИ С КАРТИНКАМИ
 Реализовано:
- Веб-страница /broadcast
- Загрузка картинок через браузер
- Предпросмотр перед отправкой
- Отправка в один клик
- Рассылка верифицированным + в чат

🎯 Как использовать:
1. Веб-админка → Рассылки
2. Ввести текст
3. Прикрепить картинку (необязательно)
4. Предпросмотр
5. Отправить

💡 Преимущества:
- Удобно с телефона/планшета
- Не нужен Telegram для отправки
- Визуальный предпросмотр
- Вся история в веб-интерфейсе

📁 Файлы:
- web/app.py — API рассылок
- web/templates/broadcast.html — форма
- web/templates/dashboard.html — меню

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-03-04 18:41:59 +00:00

153 lines
8.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Рассылки - Домовой Бот</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css" rel="stylesheet">
<style>
.sidebar { min-height: 100vh; background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%); }
.sidebar .nav-link { color: rgba(255,255,255,0.8); padding: 1rem; }
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: white; background-color: rgba(255,255,255,0.1); }
.content { padding: 2rem; }
#preview { max-width: 400px; margin-top: 1rem; display: none; }
#preview img { max-width: 100%; border-radius: 8px; }
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-2 sidebar p-0">
<div class="p-3 text-white text-center">
<h4><i class="bi bi-house-door"></i> Домовой Бот</h4>
</div>
<nav class="nav flex-column">
<a class="nav-link" href="/"><i class="bi bi-speedometer2"></i> Дашборд</a>
<a class="nav-link" href="/users"><i class="bi bi-people"></i> Пользователи</a>
<a class="nav-link" href="/verification"><i class="bi bi-shield-check"></i> Верификация</a>
<a class="nav-link" href="/phones"><i class="bi bi-telephone"></i> Телефоны</a>
<a class="nav-link active" href="/broadcast"><i class="bi bi-broadcast"></i> Рассылки</a>
<a class="nav-link" href="/polls"><i class="bi bi-bar-chart"></i> Опросы</a>
<a class="nav-link" href="/events"><i class="bi bi-calendar-event"></i> События</a>
<a class="nav-link" href="/schedules"><i class="bi bi-clock"></i> Расписания</a>
<a class="nav-link" href="/export"><i class="bi bi-download"></i> Экспорт</a>
<a class="nav-link" href="/settings"><i class="bi bi-gear"></i> Настройки</a>
</nav>
</div>
<div class="col-md-10 content">
<h2 class="mb-4"><i class="bi bi-broadcast"></i> Рассылка объявлений</h2>
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="mb-0"><i class="bi bi-send"></i> Создать рассылку</h5>
</div>
<div class="card-body">
<form id="broadcastForm" enctype="multipart/form-data">
<div class="mb-3">
<label class="form-label">Текст объявления</label>
<textarea class="form-control" id="broadcastText" rows="5"
placeholder="Введите текст объявления..." required></textarea>
<small class="text-muted">Поддерживается HTML: &lt;b&gt;жирный&lt;/b&gt;, &lt;i&gt;курсив&lt;/i&gt;</small>
</div>
<div class="mb-3">
<label class="form-label">Картинка (необязательно)</label>
<input type="file" class="form-control" id="broadcastPhoto" accept="image/*"
onchange="previewImage()">
<small class="text-muted">JPG, PNG до 5MB</small>
<div id="preview">
<img id="previewImg" alt="Предпросмотр">
</div>
</div>
<div class="alert alert-info">
<i class="bi bi-info-circle"></i>
<b>Получатели:</b> Все верифицированные пользователи + общий чат
</div>
<button type="submit" class="btn btn-primary btn-lg">
<i class="bi bi-send"></i> Отправить рассылку
</button>
</form>
<div id="result" class="mt-4"></div>
</div>
</div>
<div class="card mt-4">
<div class="card-body">
<h5>Как использовать:</h5>
<ol>
<li>Введите текст объявления</li>
<li>Прикрепите картинку (необязательно)</li>
<li>Нажмите "Отправить рассылку"</li>
<li>Бот отправит всем верифицированным пользователям в личку</li>
<li>Также отправит в общий чат</li>
</ol>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
function previewImage() {
const file = document.getElementById('broadcastPhoto').files[0];
const preview = document.getElementById('preview');
const previewImg = document.getElementById('previewImg');
if (file) {
const reader = new FileReader();
reader.onload = function(e) {
previewImg.src = e.target.result;
preview.style.display = 'block';
}
reader.readAsDataURL(file);
} else {
preview.style.display = 'none';
}
}
document.getElementById('broadcastForm').addEventListener('submit', async (e) => {
e.preventDefault();
const text = document.getElementById('broadcastText').value;
const photo = document.getElementById('broadcastPhoto').files[0];
const resultDiv = document.getElementById('result');
if (!text.trim()) {
alert('Введите текст объявления!');
return;
}
if (!confirm('Отправить рассылку всем верифицированным пользователям?')) return;
resultDiv.innerHTML = '<div class="alert alert-info">📤 Отправка рассылки...</div>';
const formData = new FormData();
formData.append('text', text);
if (photo) {
formData.append('photo', photo);
}
try {
const r = await fetch('/api/broadcast/send', {
method: 'POST',
body: formData
});
const result = await r.json();
if (result.success) {
resultDiv.innerHTML = `<div class="alert alert-success">✅ ${result.message}</div>`;
document.getElementById('broadcastForm').reset();
document.getElementById('preview').style.display = 'none';
} else {
resultDiv.innerHTML = `<div class="alert alert-danger">❌ Ошибка: ${result.error || 'Неизвестная'}</div>`;
}
} catch (err) {
resultDiv.innerHTML = `<div class="alert alert-danger">❌ Ошибка: ${err.message}</div>`;
}
});
</script>
</body>
</html>