Fitur A - Notifikasi Login PPPoE (on-up)
:local nama "$user"
:local botToken "{{BOT_TOKEN}}"
:local chatId "{{CHAT_ID}}"
:local iconLogin "\F0\9F\9F\A2"
:local iconWarn "\E2\9A\A0"
:local antiSpamThreshold 30
:local antiSpamPercent 35
:local active [:len [/ppp active find]]
:local secret [:len [/ppp secret find where disabled=no]]
:local off ($secret - $active)
:if ($off < 0) do={ :set off 0 }
:if (($secret >= $antiSpamThreshold) and (($active * 100) <= ($secret * $antiSpamPercent))) do={
:log warning ($iconWarn . " skip notif login " . $nama . " karena terdeteksi recovery massal: active=" . $active . " secret=" . $secret . " off=" . $off)
:return
}
:local ipaddress $"remote-address"
:local lastcall $"caller-id"
:local secretId [/ppp secret find where name=$nama]
:local profile "-"
:local lastdic "-"
:if ([:len $secretId] > 0) do={
:set secretId [:pick $secretId 0]
:set profile [/ppp secret get $secretId profile]
:set lastdic [/ppp secret get $secretId last-disconnect-reason]
}
:local text ($iconLogin . " LOGIN" . "\nUser : " . $nama . "\nIP Address : " . $ipaddress . "\nProfile : " . $profile . "\nLast Caller ID : " . $lastcall . "\nLast Disconnect Reason : " . $lastdic)
{{STATUS_BLOCK}}
:local payload ("{\"chat_id\":\"" . $chatId . "\",\"text\":\"" . $text . "\"}")
:do {
/tool fetch mode=https check-certificate=no http-method=post http-header-field="Content-Type: application/json" http-data=$payload url=("https://api.telegram.org/bot" . $botToken . "/sendMessage") keep-result=no
} on-error={
:log warning "gagal kirim notifikasi login"
}