← Главная

📢 Массовая рассылка

Отправить сообщение всем участникам

Предпросмотр:
Начните вводить текст...
Поддерживается HTML-разметка Telegram: <b> жирный, <i> курсив, <u> подчёркнутый, <s> зачёркнутый, <a href="..."> ссылка

📷 Прикрепить изображение (опционально)

👥
Получатели Загрузка...
0
Отправлено
0
Ошибок
image').src = e.target.result; document.getElementById('image-preview').style.display = 'block'; }; reader.readAsDataURL(file); } function removeImage() { uploadedImageBase64 = null; document.getElementById('broadcast-image').value = ''; document.getElementById('image-preview').style.display = 'none'; } async function sendBroadcast() { const text = document.getElementById('message-text').value.trim(); if (!text) { showNotification('Введите текст сообщения', 'error'); return; } if (!confirm('Отправить сообщение всем участникам?')) return; const sendBtn = document.getElementById('send-btn'); sendBtn.disabled = true; sendBtn.textContent = '⏳ Отправка...'; try { const response = await fetch(`${API_URL}/api/broadcast`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ text, image_base64: uploadedImageBase64 }) }); const result = await response.json(); if (response.ok) { document.getElementById('result-title').textContent = '✅ Рассылка завершена'; document.getElementById('stat-success').textContent = result.success_count || 0; document.getElementById('stat-failed').textContent = result.failed_count || 0; document.getElementById('stat-total').textContent = result.total_count || 0; const resultDiv = document.getElementById('broadcast-result'); resultDiv.className = 'broadcast-result success'; resultDiv.style.display = 'block'; showNotification('Рассылка выполнена', 'success'); } else { showNotification(result.detail || 'Ошибка отправки', 'error'); } } catch (error) { console.error('Error:', error); showNotification('Ошибка отправки', 'error'); } finally { sendBtn.disabled = false; sendBtn.textContent = '📤 Отправить всем'; } } async function sendPreview() { const text = document.getElementById('message-text').value.trim(); if (!text) { showNotification('Введите текст сообщения', 'error'); return; } try { const response = await fetch(`${API_URL}/api/broadcast/preview`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', body: JSON.stringify({ text, image_base64: uploadedImageBase64 }) }); if (response.ok) { showNotification('Тестовое сообщение отправлено', 'success'); } else { const error = await response.json(); showNotification(error.detail || 'Ошибка', 'error'); } } catch (error) { showNotification('Ошибка отправки', 'error'); } } document.addEventListener('DOMContentLoaded', async () => { await requireAuth(); await loadParticipantsCount(); });