mirror of
https://github.com/furaihan/simple-mikrotik-script.git
synced 2025-06-20 21:35:44 +02:00
92 lines
4.3 KiB
Text
92 lines
4.3 KiB
Text
#Add a new scheduler setting with following event:
|
|
#Change telegram chat id below with your own
|
|
:global CHATID ("-4936xxx")
|
|
#Change telegram bot id below with your own
|
|
:global BOTID ("62xxxxxxxx:AAExxxx")
|
|
:global GetMacVendor do={
|
|
:do {
|
|
return ([/tool fetch mode=https http-method=get url=("https://api.macvendors.com/".[:pick [:tostr $1] 0 8 ]) as-value output=user ]->"data")
|
|
} on-error={
|
|
return "vendor not found"
|
|
}
|
|
}
|
|
#source: https://s.id/q4f-O
|
|
:global ConvertLowerCase do={
|
|
:local alphabet {"A"="a";"B"="b";"C"="c";"D"="d";"E"="e";"F"="f";"G"="g";"H"="h";"I"="i";"J"="j";"K"="k";"L"="l";"M"="m";"N"="n";"O"="o";"P"="p";"Q"="q";"R"="r";"S"="s";"T"="t";"U"="u";"V"="v";"X"="x";"Z"="z";"Y"="y";"W"="w"};
|
|
:local result
|
|
:local character
|
|
:for strings from=0 to=([:len $1] - 1) do={
|
|
:local single [:pick $1 $strings]
|
|
:set character ($alphabet->$single)
|
|
:if ([:typeof $character] = "str") do={set single $character}
|
|
:set result ($result.$single)
|
|
}
|
|
:return $result
|
|
}
|
|
|
|
:global ConvertUpperCase do={
|
|
:local alphabet {"a"="A";"b"="B";"c"="C";"d"="D";"e"="E";"f"="F";"g"="G";"h"="H";"i"="I";"j"="J";"k"="K";"l"="L";"m"="M";"n"="N";"o"="O";"p"="P";"q"="Q";"r"="R";"s"="S";"t"="T";"u"="U";"v"="V";"x"="X";"z"="Z";"y"="Y";"w"="W"};
|
|
:local result
|
|
:local character
|
|
:for strings from=0 to=([:len $1] - 1) do={
|
|
:local single [:pick $1 $strings]
|
|
:set character ($alphabet->$single)
|
|
:if ([:typeof $character] = "str") do={set single $character}
|
|
:set result ($result.$single)
|
|
}
|
|
:return $result
|
|
}
|
|
:global ConnectionAvailable do={
|
|
:local internet
|
|
/tool flood-ping 8.8.8.8 count=10 do={
|
|
/if ($received > 8) do={
|
|
:set $internet true;
|
|
} else={
|
|
:set internet false;
|
|
}
|
|
}
|
|
:return $internet
|
|
}
|
|
#This script is inspired by TSOKOTSA's script published in the Mikrotik forum
|
|
:global GenerateRandomString do={
|
|
:local hour [:pick [/system clock get time] 0 2]
|
|
:local hourx
|
|
:local minute [:pick [/system clock get time] 3 5]
|
|
:local minutex
|
|
:local second [:pick [/system clock get time] 6 8]
|
|
:local secondx
|
|
:local hundred ("1$second")
|
|
:local hundred2 ("1$minute")
|
|
:local hundred3 ("1$hour")
|
|
:local utsec
|
|
:local uthour
|
|
:local utmin
|
|
:local uptime [/system resource get uptime]
|
|
:if ([:len $uptime] = 10) do={:set utsec [:pick $uptime 8 10]; :set utmin [:pick $uptime 5 7]; :set uthour [:pick $uptime 2 4]}
|
|
:if ([:len $uptime] = 11) do={:set utsec [:pick $uptime 9 11]; :set utmin [:pick $uptime 6 8]; :set uthour [:pick $uptime 3 5]}
|
|
:if ([:len $uptime] = 12) do={:set utsec [:pick $uptime 10 12]; :set utmin [:pick $uptime 7 9]; :set uthour [:pick $uptime 4 6]}
|
|
:if ([:len $uptime] = 8) do={:set utsec [:pick $uptime 6 8]; :set utmin [:pick $uptime 3 5]; :set uthour [:pick $uptime 0 2]}
|
|
:if (([:len $uptime] != 12) and ([:len $uptime] != 10) and ([:len $uptime] != 11) and ([:len $uptime] != 8)) do={
|
|
/log error message="Script error please contact the creator"
|
|
}
|
|
:if (([:pick $hour 1] = [:pick $hour 0]) or ([:pick $minute 1] = [:pick $minute 0]) or ([:pick $second 1] = [:pick $second 0])) do={
|
|
:set hourx (([:pick $hour 1].[:pick $hour 0]) + 1)
|
|
:set minutex (([:pick $minute 1].[:pick $minute 0]) + 1)
|
|
:set secondx (([:pick $second 1].[:pick $second 0]) + 8)
|
|
} else={
|
|
:set hourx ([:pick $hour 1].[:pick $hour 0])
|
|
:set minutex ([:pick $minute 1].[:pick $minute 0])
|
|
:set secondx ([:pick $second 1].[:pick $second 0])
|
|
}
|
|
:if ($hundred2 = $hundred) do={:set hundred2 ($hundred2 + $hour + 1)}
|
|
:if (($hundred3 = $hundred) or ($hundred3 = $hundred2)) do={ :set hundred3 ($hundred3 + $second)}
|
|
:if ($minute + $utsec - $hour < 5) do={
|
|
:set utsec ($utsec + 25)
|
|
:set minute ($minute + 60)
|
|
}
|
|
:local string ("fmIHMh52a2sSFIkSCxXkazAiBN09ypjm8F7fK0TxwTGXzaf054139uXhkEwF13Byi58JoA3lvfQr4Y6Ff257Nn5j06FI4eyzskfZybp9KjTnF9YATlBlTfP5j9uzTHspdnY6GfdQA4ekCl83qX2h382FlJv2iQFQPVZfFl15zBcqiV6TQlG3ytdQNyYJWEFy61305atf965w39iP4k6CCM5Ol0wdYZHFfcc0xFpr1ONybU9Dc3FtMCiDaGIzHu9BW4faZE2s938qs9j07pPiCfuD8OWqFEX9ukPkLl4kuNq3VjYJ1Av7W5n2")
|
|
:local RandomString
|
|
:set RandomString ([:pick $string ($second + uthour)].[:pick $string ($secondx + $uthour)].[:pick $string ($minute + $utsec - $hour)].[:pick $string ($minute + $uthour + $secondx)].[:pick $string [:tonum ($hundred + $uthour)]].[:pick $string [:tonum ($hundred2 + $utsec)]].[:pick $string [:tonum $hundred3]].[:pick $string ($utmin + $hourx + $second)].[:pick $string ($hourx + $hour + $second)].[:pick $string ($secondx + $utsec)])
|
|
:return $RandomString
|
|
}
|
|
|