fix(telegram): multi admin ID, chunk pesan, IPv4
All checks were successful
CI / test (push) Successful in 1m37s

- admin ID dipisah koma/titik-koma/spasi
- notifyAdmin chunk 4000 char + fallback plain
- dns ipv4first untuk hindari aggregate error
- versi 0.6.15
This commit is contained in:
oxpoe
2026-11-06 11:22:04 +07:00
parent 31e8f46e03
commit 81d6e79e90
5 changed files with 35 additions and 11 deletions

View File

@@ -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

View File

@@ -11,7 +11,7 @@
<p align="center">
<img src="https://img.shields.io/badge/lisensi-ISC-ADFF2F" alt="Lisensi: ISC">
<img src="https://img.shields.io/badge/versi-0.6.14_portal--custom-ADFF2F" alt="Versi 0.6.14 (portal-custom)">
<img src="https://img.shields.io/badge/versi-0.6.15_telegram--safe-ADFF2F" alt="Versi 0.6.15 (telegram-safe)">
<img src="https://img.shields.io/badge/Node.js-%E2%89%A520-339933" alt="Node.js >= 20">
<img src="https://img.shields.io/badge/docker-ready-2496ED?logo=docker&logoColor=white" alt="Docker">
<a href="https://demo-openisp.oxpoe.xyz"><img src="https://img.shields.io/badge/demo-live-ADFF2F?logo=googlechrome&logoColor=black" alt="Demo"></a>

View File

@@ -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": {

View File

@@ -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; }

View File

@@ -1 +1 @@
0.6.14
0.6.15