diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a8160..aeb427c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Format mengikuti [Keep a Changelog](https://keepachangelog.com/) dan [Semantic Versioning](https://semver.org/). +## [0.6.15] — 2026-11-06 — "telegram-safe" + +### Diperbaiki +- Telegram admin mendukung **beberapa chat ID** (pisah koma/titik-koma/spasi). +- Notifikasi admin dipecah otomatis bila pesan terlalu panjang (batas 4000 karakter). +- DNS Telegram diarahkan ke **IPv4** untuk menghindari aggregate error IPv6. + ## [0.6.14] — 2026-11-06 — "portal-custom" ### Ditambahkan diff --git a/README.md b/README.md index 96b8f22..798815a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@

Lisensi: ISC - Versi 0.6.14 (portal-custom) + Versi 0.6.15 (telegram-safe) Node.js >= 20 Docker Demo diff --git a/package.json b/package.json index a623a5d..c22397f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "open-isp", - "version": "0.6.14", + "version": "0.6.15", "description": "OPEN-ISP \u2014 sistem billing & manajemen ISP open-source (PWA pelanggan, multi-OLT, RADIUS, WhatsApp, QRIS)", "main": "app-customer.js", "scripts": { diff --git a/services/telegramBot.js b/services/telegramBot.js index 7114971..4ad10ea 100644 --- a/services/telegramBot.js +++ b/services/telegramBot.js @@ -1,3 +1,5 @@ +const dns = require('dns'); +try { dns.setDefaultResultOrder('ipv4first'); } catch (e) {} const { CompatBot } = require('./telegramCompat'); const { getSetting, getNowLocal } = require('../config/settingsManager'); const { logger } = require('../config/logger'); @@ -76,10 +78,14 @@ function initTelegram() { }).catch(e => logger.error('Telegram Bot Error (getMe):', e.message)); }).catch(e => logger.error('Telegram Bot Error (deleteWebHook):', e.message)); - // Middleware Admin Check (Fetch latest ID every time) + // Admin Check — dukung beberapa ID (pisahkan koma/titik-koma/spasi) + const getAdminIds = () => { + const raw = String(getSetting('telegram_admin_id', '') || getSetting('telegram_admin_chat_id', '') || ''); + return raw.split(/[,;\s]+/).map(s => s.trim()).filter(Boolean); + }; const isAdmin = (msg) => { - const currentAdminId = getSetting('telegram_admin_id', '').toString(); - return msg.from.id.toString() === currentAdminId; + const id = String(msg?.from?.id || ''); + return !!id && getAdminIds().includes(id); }; // Helper Mikhmon Parser @@ -1178,13 +1184,24 @@ function initTelegram() { // Export for manual re-init from settings async function notifyAdmin(text) { try { - const adminId = String(getSetting('telegram_admin_id', '') || '').trim(); - if (!bot || !adminId || !text) return false; - const ids = adminId.split(/[,s]+/).filter(Boolean); + const raw = String(getSetting('telegram_admin_id', '') || getSetting('telegram_admin_chat_id', '') || ''); + const ids = raw.split(/[,;\s]+/).map(s => s.trim()).filter(Boolean); + if (!bot || !ids.length || !text) return false; + + // Telegram membatasi panjang pesan; pecah dengan aman. + const str = String(text); + const maxLen = 4000; + const chunks = []; + for (let i = 0; i < str.length; i += maxLen) chunks.push(str.slice(i, i + maxLen)); + let ok = false; for (const id of ids) { - try { await bot.sendMessage(id, text, { parse_mode: 'Markdown' }); ok = true; } - catch (e) { try { await bot.sendMessage(id, String(text)); ok = true; } catch (e2) {} } + for (const chunk of chunks) { + try { await bot.sendMessage(id, chunk, { parse_mode: 'Markdown' }); ok = true; } + catch (e) { + try { await bot.sendMessage(id, chunk); ok = true; } catch (e2) {} + } + } } return ok; } catch (e) { return false; } diff --git a/version.txt b/version.txt index 5c858bd..7e3c84c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.6.14 \ No newline at end of file +0.6.15 \ No newline at end of file