feat(ai): provider OpenAI-compatible + DeepSeek, AI Telegram, self-healing dengan toggle (port upstream)
- telegramAiService/adminAiTools: dukung openai, deepseek, groq, openrouter, custom (base URL + key + model) - selfHealingService: billing vs isolir, konsistensi secret PPPoE, sesi RADIUS stale, IP ACS kosong - mikrotikService: getActivePppoeUsers, isolateCustomerPppoe, unisolateCustomerPppoe (upstream memanggil fungsi yang tidak ada) - cron 30 menit hanya jalan bila ai_self_healing_enabled=true (default off) + scan brute force MikroTik tiap 2 menit - Pengaturan: kartu AI & Self-Healing (provider, key/model, toggle, tombol Diagnosa/Perbaiki) - bot Telegram: pesan non-command dari admin dijawab AI
This commit is contained in:
@@ -312,10 +312,25 @@ function initTelegram() {
|
||||
|
||||
bot.on('message', async (msg) => {
|
||||
if (!isAdmin(msg)) return;
|
||||
const text = msg.text;
|
||||
if (text === '/start' || text === '/menu') return; // Handled by onText
|
||||
|
||||
// Logika handle text manual jika diperlukan (misal untuk perintah kick/edit)
|
||||
const text = String(msg.text || '').trim();
|
||||
if (!text || text.startsWith('/')) return; // command ditangani onText
|
||||
if (text === '/start' || text === '/menu') return;
|
||||
|
||||
try {
|
||||
bot.sendChatAction(msg.chat.id, 'typing').catch(() => {});
|
||||
const telegramAi = require('./telegramAiService');
|
||||
const answer = await telegramAi.askAi({
|
||||
question: text,
|
||||
senderName: (msg.from && msg.from.first_name) || 'Admin',
|
||||
isAdmin: true
|
||||
});
|
||||
if (!answer) return;
|
||||
const clean = typeof telegramAi.cleanAiResponse === 'function' ? telegramAi.cleanAiResponse(answer) : answer;
|
||||
await bot.sendMessage(msg.chat.id, clean, { parse_mode: 'Markdown', reply_to_message_id: msg.message_id })
|
||||
.catch(() => bot.sendMessage(msg.chat.id, clean, { reply_to_message_id: msg.message_id }));
|
||||
} catch (e) {
|
||||
logger.error('[TelegramBot] AI error: ' + e.message);
|
||||
}
|
||||
});
|
||||
|
||||
// Callback Query Handling
|
||||
|
||||
Reference in New Issue
Block a user