Update telegram.html

This commit is contained in:
Lizandro Guarnizo
2026-05-22 00:17:00 -05:00
parent c21fab079d
commit fb67a308dc
+24 -12
View File
@@ -283,22 +283,34 @@ function telegramApp() {
async testConfig(cfg) { async testConfig(cfg) {
this.testLoading[cfg.ID] = true; this.testLoading[cfg.ID] = true;
this.testResult[cfg.ID] = ''; this.testResult[cfg.ID] = '';
const res = await fetch(`/app/telegram/${cfg.ID}/test`, { method: 'POST' }); try {
const d = await res.json(); const res = await fetch(`/app/telegram/${cfg.ID}/test`, { method: 'POST' });
this.testOk[cfg.ID] = d.ok; const d = await res.json();
this.testResult[cfg.ID] = d.ok ? '✅ Mensaje enviado correctamente.' : ('❌ ' + (d.error || 'Error')); this.testOk[cfg.ID] = d.ok;
this.testLoading[cfg.ID] = false; this.testResult[cfg.ID] = d.ok ? '✅ Mensaje enviado correctamente.' : ('❌ ' + (d.error || 'Error'));
} catch (e) {
this.testOk[cfg.ID] = false;
this.testResult[cfg.ID] = '❌ Error de red: ' + e.message;
} finally {
this.testLoading[cfg.ID] = false;
}
}, },
async setWebhook(cfg) { async setWebhook(cfg) {
this.webhookLoading[cfg.ID] = true; this.webhookLoading[cfg.ID] = true;
this.webhookResult[cfg.ID] = ''; this.webhookResult[cfg.ID] = '';
const res = await fetch(`/app/telegram/${cfg.ID}/set-portal-webhook`, { method: 'POST' }); try {
const d = await res.json(); const res = await fetch(`/app/telegram/${cfg.ID}/set-portal-webhook`, { method: 'POST' });
this.webhookOk[cfg.ID] = d.ok; const d = await res.json();
this.webhookResult[cfg.ID] = d.ok this.webhookOk[cfg.ID] = d.ok;
? '✅ Webhook registrado: ' + (d.webhook_url || '') this.webhookResult[cfg.ID] = d.ok
: '❌ Error: ' + (d.telegram?.description || d.error || 'Error desconocido'); ? '✅ Webhook registrado: ' + (d.webhook_url || '')
this.webhookLoading[cfg.ID] = false; : '❌ Error: ' + (d.telegram?.description || d.error || 'Error desconocido');
} catch (e) {
this.webhookOk[cfg.ID] = false;
this.webhookResult[cfg.ID] = '❌ Error de red: ' + e.message;
} finally {
this.webhookLoading[cfg.ID] = false;
}
}, },
async sendMessage() { async sendMessage() {