āĻ¸āĻŦ āĻāĻ¤ āĻā§āĻāĻŋāĻ° āĻ¸āĻā§āĻā§. āĻāĻ āĻĨāĻŋāĻŽ āĻāĻ°āĻ āĻāĻžāĻ˛
āĻ¸āĻžāĻ§āĻžāĻ°āĻŖāĻāĻžāĻŦā§, āĻ āĻĒāĻžāĻ°ā§āĻļāĻ¨ā§āĻ° āĻ¨ā§āĻ¤āĻŋāĻāĻŋ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻŋāĻ¤ āĻšāĻ¯āĻŧāĻ¨āĻŋ, āĻļā§āĻ§ā§āĻŽāĻžāĻ¤ā§āĻ° āĻĒāĻžāĻ°ā§āĻĨāĻā§āĻ¯ āĻšāĻ˛ āĻ¯ā§ āĻāĻāĻ¨ āĻāĻāĻŋ āĻĻā§āĻ°āĻŋ āĻ¨āĻž āĻāĻ°ā§ āĻ¤āĻžāĻ¤ā§āĻā§āĻˇāĻŖāĻŋāĻāĻāĻžāĻŦā§ āĻāĻžāĻ āĻāĻ°ā§āĨ¤
āĻāĻŽāĻ°āĻž āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ Mikrotik āĻ āĻāĻĒāĻ˛ā§āĻĄ āĻāĻ°āĻŋ, BotID āĻāĻŦāĻ ChatID āĻāĻŽāĻžāĻĻā§āĻ° āĻ¨āĻŋāĻāĻ¸ā§āĻŦ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻāĻ°āĻŋ āĻāĻŦāĻ āĻāĻ° āĻāĻ¨ā§āĻ¯ āĻāĻāĻāĻŋ āĻ¸āĻŽāĻ¯āĻŧāĻ¸ā§āĻā§ āĻ¤ā§āĻ°āĻŋ āĻāĻ°āĻŋāĨ¤ āĻ¸ā§āĻāĻžāĻ°ā§āĻāĻāĻĒā§ "āĻ¸ā§āĻāĻžāĻ°ā§āĻ āĻāĻžāĻāĻŽ" āĻĒā§āĻ¯āĻžāĻ°āĻžāĻŽāĻŋāĻāĻžāĻ° āĻ¸ā§āĻ āĻāĻ°ā§āĻ¨ (āĻ¸ā§āĻāĻžāĻ°ā§āĻāĻāĻĒā§ āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ āĻāĻžāĻ˛āĻžāĻ¨āĨ¤)
āĻŦā§āĻ¯āĻŦāĻ§āĻžāĻ¨: 00:00:00
āĻŦāĻžāĻāĻŋ āĻ¸āĻŦ āĻ¯ā§āĻŽāĻ¨ āĻāĻŋāĻ˛.
āĻā§āĻ˛āĻŋāĻā§āĻ°āĻžāĻŽ-v2
:delay 10
:global mtIdentity [/system identity get name];
:global botID "botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX" ;
:global myChatID "YYYYYY" ;
:local chatId 0;
:local messageId 0;
:local parse do={
:local startLoc ([:find $content $variable -1] + [:len $variable] + 2);
:local commaLoc ([:find $content "," $startLoc] - 1 + 1);
:local braceLoc ([:find $content "}" $startLoc] - 1 + 1);
:local endLoc $commaLoc;
:local startSymbol [:pick $content $startLoc]
:if ($braceLoc != 0 and ($commaLoc = 0 or $braceLoc < $commaLoc)) do={
:set endLoc $braceLoc;
};
:if ($startSymbol = "{") do={
:set endLoc ($braceLoc + 1);
};
:if ($quotas = true) do={
:set startLoc ($startLoc + 1);
:set endLoc ($endLoc - 1);
}
:if ($endLoc < $startLoc) do={
:set endLoc ($startLoc + 1);
};
:local message [:pick $content $startLoc $endLoc]
#:log info $message;
:return $message;
}
:while ( true ) do={
:do {
#:log info "https://api.telegram.org/$botID/getUpdates?offset=$messageId&limit=1&allowed_updates=message&timeout=60";
:tool fetch url=("https://api.telegram.org/$botID/getUpdates?offset=$messageId&limit=1&allowed_updates=message&timeout=60") dst-path="getUpdates";
:local content [/file get [/file find name=getUpdates] contents] ;
#:log info $content;
:if ([:len $content] > 30) do={
:set messageId ([$parse content=$content variable="update_id"] + 1)
:local message [$parse content=$content variable="text" quotas=true]
:local chat [$parse content=$content variable="chat"]
:local chatId [$parse content=$chat variable="id"]
:if (($chatId = $myChatID) and ([/system script find name=$message] != "")) do={
:system script run $message;
} else={
:tool fetch url=("https://api.telegram.org/$botID/sendmessage?chat_id=$chatId&text=$mtIdentity: Unknown command: $message") keep-result=no
}
}
} on-error={}
};
āĻāĻ¯āĻŧā§āĻ āĻŦāĻāĻ°ā§āĻ° āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°ā§āĻ° āĻāĻ¨ā§āĻ¯, āĻāĻāĻāĻŋ āĻŦāĻžāĻ āĻĒā§āĻ°āĻāĻžāĻļāĻŋāĻ¤ āĻšāĻ¯āĻŧā§āĻāĻŋāĻ˛, āĻāĻŋāĻā§ āĻāĻžāĻ°āĻŖā§, āĻĻā§āĻ°ā§āĻŦāĻ˛ āĻŽāĻŋāĻā§āĻ°ā§āĻāĻŋāĻ āĻā§āĻ¨āĻ āĻāĻžāĻ°āĻŖā§ āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ āĻŦāĻ¨ā§āĻ§ āĻāĻ°ā§ āĻĻā§āĻ¯āĻŧ, āĻāĻ°āĻ āĻļāĻā§āĻ¤āĻŋāĻļāĻžāĻ˛ā§āĻā§āĻ˛āĻŋāĻ° āĻāĻĒāĻ° āĻāĻāĻŋ āĻ āĻŦāĻŋāĻ°āĻžāĻŽ āĻāĻžāĻ āĻāĻ°ā§āĨ¤
āĻāĻ āĻāĻĻā§āĻĻā§āĻļā§āĻ¯ā§, āĻāĻŽāĻŋ āĻāĻāĻāĻŋ āĻāĻ¯āĻŧāĻžāĻāĻĄāĻ āĻā§āĻ°āĻžāĻ āĻ¨āĻŋāĻā§āĻˇā§āĻĒ āĻāĻ°ā§āĻāĻŋāĨ¤ āĻāĻāĻžāĻ¨ā§ āĻāĻŽāĻ°āĻž āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻā§āĻ° āĻ¨āĻžāĻŽāĻāĻŋ āĻāĻĒāĻ°ā§ āĻ¨āĻŋāĻ°ā§āĻĻā§āĻļāĻŋāĻ¤ āĻāĻāĻāĻŋāĻ¤ā§ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻāĻ°āĻŋāĨ¤ āĻāĻŦāĻ āĻ°āĻŋāĻ¸ā§āĻāĻžāĻ°ā§āĻā§āĻ° āĻŦā§āĻ¯āĻŦāĻ§āĻžāĻ¨ 5 āĻŽāĻŋāĻ¨āĻŋāĻā§ āĻ¸ā§āĻ āĻāĻ°ā§āĻ¨āĨ¤ āĻĒā§āĻ°āĻ¤āĻŋ 5 āĻŽāĻŋāĻ¨āĻŋāĻā§, āĻāĻŽāĻžāĻĻā§āĻ° "āĻāĻ¯āĻŧāĻžāĻ āĻĄāĻ" āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ āĻĒāĻ°ā§āĻā§āĻˇāĻž āĻāĻ°āĻŦā§ āĻāĻŦāĻ āĻ¯āĻĻāĻŋ āĻāĻāĻŋ āĻāĻžāĻ āĻ¨āĻž āĻāĻ°ā§ āĻ¤āĻŦā§ āĻāĻāĻŋ āĻāĻžāĻ˛āĻžāĻŦā§āĨ¤
WatchDogT.me
:global scriptname "t.me"
:if ([:len [/system script job find script=$"scriptname"]] > 0) do={
:log info "$scriptname Already Running - killing old script before continuing"
:foreach counter in=[/system script job find script=$"scriptname"] do={
/system script job remove $counter
}
}
/system script run $scriptname
āĻāĻŦāĻ āĻĄā§āĻāĻžāĻ°ā§āĻā§āĻ° āĻāĻ¨ā§āĻ¯, āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ Mikrotik āĻĢā§āĻ°āĻžāĻŽ āĻĨā§āĻā§ āĻ¨ā§āĻāĻ¯āĻŧāĻž āĻšāĻ¯āĻŧā§āĻā§āĨ¤
āĻ˛āĻ āĻĨā§āĻā§ āĻāĻŽāĻžāĻĻā§āĻ° āĻāĻžāĻ°ā§āĻā§ āĻā§āĻ°ā§āĻ¤ā§āĻŦāĻĒā§āĻ°ā§āĻŖ āĻŦāĻŋāĻˇāĻ¯āĻŧ āĻĒāĻžāĻ āĻžāĻ¯āĻŧāĨ¤
āĻ¸ā§āĻā§āĻ°āĻŋāĻĒā§āĻāĻāĻŋ āĻ¸āĻŽāĻ¯āĻŧāĻ¸ā§āĻā§āĻ¤ā§ āĻ¨āĻŋāĻā§āĻˇā§āĻĒ āĻāĻ°ā§āĻ¨ āĻāĻŦāĻ āĻĒā§āĻ°āĻ¤āĻŋ 5 āĻŽāĻŋāĻ¨āĻŋāĻā§ āĻĒā§āĻ¨āĻāĻ¸ā§āĻāĻ¨āĻž āĻŦā§āĻ¯āĻŦāĻ§āĻžāĻ¨ āĻ¨āĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āĻ āĻāĻ°ā§āĻ¨, BotID āĻāĻŦāĻ ChatID āĻāĻĒāĻ¨āĻžāĻ° āĻ¨āĻŋāĻā§āĻ° āĻŽāĻ¤ āĻĒāĻ°āĻŋāĻŦāĻ°ā§āĻ¤āĻ¨ āĻāĻ°ā§āĻ¨āĨ¤
notify-log
:global lastTime
:global output
:global mtIdentity [/system identity get name];
:global botID "botXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX" ;
:global myChatID "YYYYYY" ;
:local LogGet [ :toarray [ /log find topics~"critical" || message~"login failure" || message~"[Ff]ailure" ] ] ;
:local LogtLineCount [ :len $LogGet ] ;
if ($LogtLineCount > 0) do={
:local currentTime "$[ /log get [ :pick $LogGet ($LogtLineCount -1) ] time ]";
:if ([:len $currentTime] = 10 ) do={
:set currentTime [ :pick $currentTime 0 10 ];
}
:set output "$currentTime - $[/log get [ :pick $LogGet ($LogtLineCount-1) ] message ]";
:if (([:len $lastTime] < 1) || (([:len $lastTime] > 0) && ($lastTime != $currentTime))) do={
:set lastTime $currentTime ;
:tool fetch url=("https://api.telegram.org/$botID/sendmessage?chat_id=$myChatID&text="$mtIdentity" : $output") keep-result=no
}
}
āĻāĻŽāĻ°āĻž āĻĢāĻ˛āĻžāĻĢāĻ˛ āĻĒāĻžāĻ:
āĻāĻ¤ā§āĻ¸: www.habr.com