DOWNLOAD THIS FILE:
https://www.mediafire.com/file/eon2syohnibd3d8/TELEGRAM+SCRIPT.zip/file
LOG IN SCRIPT(COPY THIS FILE)
### enable telegram notification, change from 0 to 1 if you want to enable telegram
:local enableTelegram 0;
###replace telegram token
:local telegramToken "2021159313:AAHEBoOLogYjLCpSwVeKPVmKKO4TIxa02vQ";
###replace telegram chat id / group id
:local chatId "xxxxxx";
### enable Random MAC synchronizer
:local enableRandomMacSyncFix 1;
### hotspot folder for HEX put flash/hotspot for haplite put hotspot only
:local hotspotFolder "hotspot";
:local com [/ip hotspot user get [find name=$user] comment];
/ip hotspot user set comment="" $user;
:if ($com!="") do={
:local mac $"mac-address";
:local macNoCol;
:for i from=0 to=([:len $mac] - 1) do={
:local char [:pick $mac $i]
:if ($char = ":") do={
:set $char ""
}
:set macNoCol ($macNoCol . $char)
}
:local validity [:pick $com 0 [:find $com ","]];
:if ( $validity!="0m" ) do={
:local sc [/sys scheduler find name=$user]; :if ($sc="") do={ :local a [/ip hotspot user get [find name=$user] limit-uptime]; :local c ($validity); :local date [ /system clock get date]; /sys sch add name="$user" disable=no start-date=$date interval=$c on-event="/ip hotspot user remove [find name=$user]; /ip hotspot active remove [find user=$user]; /file remove \"$hotspotFolder/data/$macNoCol.txt\"; /ip hotspot cookie remove [find user=$user]; /system sche remove [find name=$user]" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon; :delay 2s; } else={ :local sint [/sys scheduler get $user interval]; :if ( $validity!="" ) do={ /sys scheduler set $user interval ($sint+$validity); } };
}
:local infoArray [:toarray [:pick $com ([:find $com ","]+1) [:len $com]]];
:local mac $"mac-address";
:local totaltime [/ip hotspot user get $user limit-uptime];
:local date [ /system clock get date ];
:local time [/system clock get time ];
:local eg [/ip hotspot user get $user uptime];
:local rtime ($totaltime-$eg);
:local expiry [/sys sch get [/sys sch find where name=$user] next-run];
:local host [/ip dhcp-server lease get [ find mac-address=$mac ] host-name];
:local tu [/ip hotspot user print count-only];
:local amt [:pick $infoArray 0];
:local ext [:pick $infoArray 1];
:local vendo [:pick $infoArray 2];
:local uactive [/ip hotspot active print count-only];
:local idle ( $tu - $uactive );
:local getIncome [:put ([/system script get [find name=todayincome] source])];
/system script set source="$getIncome" todayincome;
:local getSales ($amt + $getIncome);
/system script set source="$getSales" todayincome;
:local getMonthlyIncome [:put ([/system script get [find name=monthlyincome] source])];
/system script set source="$getMonthlyIncome" monthlyincome;
:local getMonthlySales ($amt + $getMonthlyIncome);
/system script set source="$getMonthlySales" monthlyincome;
:local getLifetimeIncome [:put ([/system script get [find name=lifetimeincome] source])];
/system script set source="$getLifetimeIncome" lifetimeincome;
:local getLifetimeSales ($amt + $getLifetimeIncome);
/system script set source="$getLifetimeSales" lifetimeincome;
:local validUntil [/sys scheduler get $user next-run];
/file print file="$hotspotFolder/data/$macNoCol" where name="noname.txt";
:delay 1s;
/file set [find name="$hotspotFolder/data/$macNoCol.txt"] contents="";
:delay 1s;
/file set "$hotspotFolder/data/$macNoCol.txt" contents="$user#$validUntil";
:delay 1s;
:if ($enableTelegram=1) do={
:local vendoNew;
:for i from=0 to=([:len $vendo] - 1) do={
:local char [:pick $vendo $i]
:if ($char = " ") do={
:set $char "%20"
}
:set vendoNew ($vendoNew . $char)
}
/tool fetch url="https://api.telegram.org/bot$telegramToken/sendmessage?chat_id=$chatId&text=<<======New Sales======>> %0A VENDO: $vendo %0A%0A VOUCHER: $user %0A%0A LOGIN:%0A $date $time%0AVALID UNTIL:%0A $expiry%0ATOTAL TIME PURCHASED:%0A $totaltime%0ATOTAL REMAINING TIME:%0A $rtime%0ADevice: $host%0AMAC: $mac%0AIP: $address%0AAmount: $amt.00%0AExtended: $ext%0AToday Sales: $getSales.00%0AMonthly Sales: $getMonthlySales.00 %0ALifetime Sales: $getLifetimeSales.00%0AActive users: $uactive Inactive: $idle%0A<<====================>>" keep-result=no;
}
};
:if ($enableRandomMacSyncFix=1) do={
:local cmac $"mac-address"
:foreach AU in=[/ip hotspot active find user="$username"] do={
:local amac [/ip hotspot active get $AU mac-address];
:if ($cmac!=$amac) do={ /ip hotspot active remove [/ip hotspot active find mac-address="$amac"]; }
}
}
LOG OUT SCRIPT(COPY THIS FILE)
### hotspot folder for HEX put flash/hotspot for haplite put hotspot only
:local hotspotFolder "hotspot";
:local mac $"mac-address";
:local macNoCol;
:for i from=0 to=([:len $mac] - 1) do={
:local char [:pick $mac $i]
:if ($char = ":") do={
:set $char ""
}
:set macNoCol ($macNoCol . $char)
}
:if ([/ip hotspot user get [/ip hotspot user find where name="$user"] limit-uptime] <= [/ip hotspot user get [/ip hotspot user find where name="$user"] uptime]) do={
/ip hotspot user remove $user;
/file remove "$hotspotFolder/data/$macNoCol.txt";
/system sche remove [find name=$user];
}
SCRIPT FOR TERMINAL(COPY AND PASTE TO TERMINAL)
##Paste this to terminal if you used the included on-login and on-logout script:
/system scheduler add interval=1d name="Reset Daily Income" on-event="/system script set source=\"0\" todayincome " policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=Sep/28/2021 start-time=00:00:00;
/system scheduler add interval=30d name="Reset Monthly Income" on-event="/system script set source=\"0\" monthlyincome " policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon start-date=Sep/28/2021 start-time=00:00:00;
/system script add dont-require-permissions=no name=todayincome owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="0";
/system script add dont-require-permissions=no name= monthlyincome owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="0";
/system script add dont-require-permissions=no name=lifetimeincome owner=admin policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source="0";