Community discussions

MikroTik App
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Hotspot user

Sat May 28, 2022 3:22 am

Greetings friends, I am just starting with a hotspot and I would like to make a script to eliminate users who have the time of one hour, but have been disconnected and before the time and do not connect after 4 hours delete those users, I don't know if you understand me, here I have a script that I use to eliminate the clients that have consumed their full time, and I have a client:


/ip hotspot user remove [find uptime=01:00:00 limit-uptime=01:00:00]

add comment=1hour limit-uptime=1h name=screp profile=1hour server=hotspot1




Thanks for helping.




EL DONCITO.
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Hotspot user

Sat May 28, 2022 4:15 pm

Rextended, you can help.
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Hotspot user

Sat May 28, 2022 5:36 pm

Got this:

{
:local tdias 0
:local atime [ /system clock get time ]
:local adate [ /system clock get date ]
:local temp1 [:pick $adate 0 3] 
:local temp2 [:pick $adate 4 6]
:local temp3 [:pick $atime 0 5]
:local temp4 ($temp2."/".$temp1." - ".$temp3."  Dias: ".$tdias);
:local thoras 4
:if ([ /ip hotspot user get $user comment ]="") do={ [ /ip hotspot user set $user comment=$temp4 ] }

:local mesarray ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
:local diaarray ("31","28","31","30","31","30","31","31","30","31","30","31")
:local day [:pick $adate 4 6]
:local monthtxt [:pick $adate 0 3]
:local year [:pick $adate 7 11]
:local months ([:find $mesarray $monthtxt])
:local dia ([:pick $diaarray $months])
:local fhora [:pick $atime 0 2]
:local fminutos [:pick $atime 3 5]
:local fsegundos [:pick $atime 6 9]
:local mayorhora (($fhora+$thoras)-24) 

 :if (($fhora+$thoras)>23) do={
     :set atime ("0".$mayorhora.":".$fminutos.":".fsegundos);
	 :set $tdias ($tdias+1);
	} else={
     :set atime (($fhora+$thoras).":".$fminutos.":".fsegundos) ;
 }
 

 :if (($day+$tdias)>$dia) do={
    :if ($months=11) do={
        
     :set months 0;
        
     :set year ($year+1);
        
     :set day (($day+$tdias)-$dia);
        
     :local mes ([:pick $mesarray $months]);
        
     :set adate ($mes."/".$day."/".$year);
        
     } else={
           
       :set months ($months+1);
           
       :set day (($day+$tdias)-$dia);
           
       :local mes ([:pick $mesarray $months]);
           
       :set adate ($mes."/".$day."/".$year);
        
       }
    
        } else={
        
          :set day ($day+$tdias);
        
          :local mes ([:pick $mesarray $months]);
        
          :set adate ($mes."/".$day."/".$year);
    
     }

[/system scheduler add name=$user on-event="/ip hotspot user remove \"$user\" \r\
  \n/ip hotspot cookie remove [find user=\"$user\"] \r\
  \n/ip dhcp-server lease remove [find dynamic] \r\
  \n/system scheduler remove [find name=\"$user\"] \r\
  \n\r\
  " start-date=$adate start-time=$atime]
 
}  

I don't know if it works for what I want.
Please check it and correct it if there is something wrong.




EL DONCITO.
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Hotspot user

Sun May 29, 2022 8:16 pm

Nobody thinks anything?
Help me please.




EL DONCITO.
 
eldoncito2019
Member
Member
Topic Author
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Hotspot user

Tue May 31, 2022 12:13 am

Friend rextended I know you will still be celebrating the victory of REAL MADRID, but give the script a review and let me know please.





EL DONCITO.

Who is online

Users browsing this forum: GoogleOther [Bot] and 18 guests