furaihan.simple-mikrotik-sc.../first-setup

50 lines
1.8 KiB
Text
Raw Normal View History

2020-08-29 00:02:52 +07:00
#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
:set GetMacVendor do={
local MacAddress [:tostr $1]
:do {
local result ([/tool fetch mode=https http-method=get url=("https://api.macvendors.com/".[:pick [:tostr $MacAddress] 0 8 ]) as-value output=user ]->"data")
return $result
} on-error={
return "Error! this probably cause from unknown vendor or a connection problem"
}
}
2020-08-29 00:02:52 +07:00
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 CheckConnection do={
global ConnectionAvailable
tool flood-ping 8.8.8.8 count=10 do={
/if ($received > 8) do={
set $ConnectionAvailable [tobool true]
} else={
set $ConnectionAvailable [tobool false]
}
}
}