furaihan.simple-mikrotik-sc.../data-usage-to-telegram

12 lines
847 B
Text
Raw Permalink Normal View History

2020-09-01 13:16:20 +07:00
:global ConnectionAvailable
$ConnectionAvailable
2020-08-29 00:52:46 +07:00
if ($ConnectionAvailable=true) do={
global CHATID
global BOTID
local wan [/ip arp get number=[find where address=[/ip route get number=[find where dst-address="0.0.0.0/0" && active=yes ] gateway]] interface]
local SendTelegram ("<b>Daily Data Usage Report:</b>%0A"."WAN Interface: $wan%0A"."Upload Usage:".([/interface get $wan tx-byte] / 1024 / 1024 / 1024)." GB%0ADownload Usage: ".([/interface get $wan rx-byte] / 1024 / 1024 / 1024)." GB%0ATotal: ".(([/interface get $wan tx-byte] / 1024 / 1024 / 1024) + ([/interface get $wan rx-byte] / 1024 / 1024 / 1024))." GB")
/tool fetch url="https://api.telegram.org/bot$BOTID/sendMessage\?chat_id=$CHATID&text=$SendTelegram&parse_mode=html" keep-result=no;
} else={
log warning message="Cannot send message to telegram. is internet connected?"
}