:global lastTimeFailure
:global outputFailure
:global mtIdentityFailure [/system identity get name];
:global botIDFailure "botX:token" ;
:global myChatIDFailure "-id чата" ;
:local LogGetFailure [ :toarray [ /log find topics~"critical" || message~"login failure" || message~"[Ff]ailure" ] ] ;
:local LogtLineCountFailure [ :len $LogGetFailure ] ;
if ($LogtLineCountFailure > 0) do={
:local currentTimeFailure "$[ /log get [ :pick $LogGetFailure ($LogtLineCountFailure -1) ] time ]";
:if ([:len $currentTimeFailure] = 10 ) do={
:set currentTimeFailure [ :pick $currentTimeFailure 0 10 ];
}
:set outputFailure "$currentTimeFailure - $[/log get [ :pick $LogGetFailure ($LogtLineCountFailure-1) ] message ]";
:if (([:len $lastTimeFailure] < 1) || (([:len $lastTimeFailure] > 0) && ($lastTimeFailure != $currentTimeFailure))) do={
:set lastTimeFailure $currentTimeFailure ;
:tool fetch url=("https://api.telegram.org/$botIDFailure/sendmessage\?chat_id=$myChatIDFailure&text=%E2%9D%8C\"$mtIdentityFailure\" : $outputFailure") keep-result=no
}
}