100% found this document useful (1 vote)
349 views3 pages

Telegram With Instructions

This document contains scripts to be run in the terminal and added to user profiles to reset income tracking variables on a schedule, send Telegram notifications for new sales, and fix issues with random MAC addresses syncing. The scripts reset daily, weekly, and monthly income to 0 on the 7th, 15th, 22nd, 30th, and 1st of each month. They also update the income variables on new sales, send a Telegram message with sale details, and remove desynced active MAC addresses for a user.

Uploaded by

Tom Jerry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
349 views3 pages

Telegram With Instructions

This document contains scripts to be run in the terminal and added to user profiles to reset income tracking variables on a schedule, send Telegram notifications for new sales, and fix issues with random MAC addresses syncing. The scripts reset daily, weekly, and monthly income to 0 on the 7th, 15th, 22nd, 30th, and 1st of each month. They also update the income variables on new sales, send a Telegram message with sale details, and remove desynced active MAC addresses for a user.

Uploaded by

Tom Jerry
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

###Run in Terminal

/system scheduler
add interval=1d name="SalesReset Main" on-event="/system script set todayincom\
e source=\"0\";\r\
\n:local todate [ /sys clock get date];\r\
\n:if ([:pic \$todate 4 6] = \"07\") do={ /system script set weeklyincome \
source=\"0\";}\r\
\n:if ([:pic \$todate 4 6] = \"15\") do={ /system script set weeklyincome \
source=\"0\";}\r\
\n:if ([:pic \$todate 4 6] = \"22\") do={ /system script set weeklyincome \
source=\"0\";}\r\
\n:if ([:pic \$todate 4 6] = \"30\") do={ /system script set weeklyincome \
source=\"0\";}\r\
\n:if ([:pic \$todate 4 6] = \"01\") do={ /system script set monthlyincome\
\_source=\"0\";}" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=sep/28/2021 start-time=[Link]

/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=weeklyincome 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";

###Put in On Log-in Script in User Profile


### enable telegram notification, change from 0 to 1 if you want to enable telegram
:local enableTelegram 1;
###replace telegram token
:local telegramToken "Your Token";
###replace telegram chat id / group id
:local chatId "Your Chat ID";
### enable Random MAC synchronizer
:local enableRandomMacSyncFix 1;
:local com [/ip hotspot user get [find name=$user] comment];
/ip hotspot user set comment="" $user;

:if ($com!="") do={


:local sc [/sys scheduler find name=$user]; :if ($sc="") do={ :local a [/ip
hotspot user get [find name=$user] limit-uptime]; :local validity [:pick $com 0
[:find $com ","]]; :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];
/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]; :local validity [:pick
$com 0 [:find $com ","]]; :if ( $validity!="" ) do={ /sys scheduler set $user
interval ($sint+$validity); } };

:local infoArray [:toarray [:pick $com ([:find $com ","]+1) [:len $com]]]

:if ($enableTelegram=1) do={


:local mac $"mac-address";
:local totaluptime [/ip hotspot user get [find name="$user"] uptime];
:local totaltime [/ip hotspot user get [find name="$user"] limit-
uptime];
:local amt [:pick $infoArray 0];
:local ext [:pick $infoArray 1];
:local vendo [:pick $infoArray 2];
:local timeleft ($totaltime - $totaluptime);
:local date [ /system clock get date ];
:local time [/system clock get time ];
:local expiry [ /sys sch get [/sys sch find where name=$user] next-run];
:local uactive [/ip hotspot active print count-only];
:local uhost [/ip dhcp-server lease get [find mac-address=$mac] host-
name];

: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 getWeeklyIncome [:put ([/system script get [find


name=weeklyincome] source])]
/system script set source="$getWeeklyIncome" weeklyincome;

:local getWeeklySales ($amt + $getWeeklyIncome)


/system script set source="$getWeeklySales" weeklyincome;

: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;

###start of additional script


:local mac $"mac-address";
:local Coins [/ip dhcp-server lease get [find mac-address=$mac] comment];
/ip dhcp-server lease set comment=($Coins."|".$amt) [find mac-
address=$mac];
:local TCoins [/ip dhcp-server lease get [find mac-address=$mac] comment];
###end of additional script
:log info (">>Customer $address inserted Php $amt");

/tool fetch
url="[Link]
chat_id=$chatId&text=<<======NEW SALES======>>%0A%0A- Vendo: $vendo %0A%0A-
Voucher: $user %0A- Device: $uhost%0A- IP: $address %0A- Mac: $mac %0A%0A- Amount:
$amt %0A- Coins Inserted: $TCoins %0A- Extended: $ext %0A- Total Time: $totaltime
%0A- Time left: $timeleft %0A- Login Time: $date $time %0A- Expiration: $expiry %0A
%0A- Daily Sales: $getSales.00 %0A- Weekly Sales: $getWeeklySales.00 %0A- Monthly
Sales : $getMonthlySales.00 %0A- Active: $uactive users%0A
%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"]; }
}
}

You might also like