{"id":296731,"date":"2020-01-04T09:00:14","date_gmt":"2020-01-04T09:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296731"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296731","title":{"rendered":"\u0423\u0434\u0430\u043b\u0451\u043d\u043d\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 Mikrotik \u0438\u0437 Telegram v 2.0"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482802\/\">\u0412\u0441\u0435\u0445 \u0441 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u043c \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u043e\u043c. \u0414\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043b\u0443\u0447\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u0434\u0430\u043b\u0435\u043a\u043e\u043c 2016 \u0442\u0443\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/314108\/\">habr.com\/ru\/post\/314108<\/a>.<\/p>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u0441 \u0442\u043e\u0439 \u043b\u0438\u0448\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0431\u0435\u0437 \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a.<\/p>\n<p>  \u0417\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 Mikrotik, \u043c\u0435\u043d\u044f\u0435\u043c BotID \u0438 ChatID \u043d\u0430 \u0441\u0432\u043e\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e schedule. \u0421\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u00abStart Time\u00bb \u043d\u0430 startup (\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.)<br \/>  \u00abInterval\u00bb: 00:00:00<br \/>  \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0441\u0435 \u043a\u0430\u043a \u0438 \u0431\u044b\u043b\u043e. <\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Telegram-v2<\/b><\/p>\n<div class=\"spoiler_text\">:delay 10<br \/>  :global mtIdentity [\/system identity get name];<br \/>  :global botID \u00abbotXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX\u00bb;<br \/>  :global myChatID \u00abYYYYYY\u00bb;<br \/>  :local chatId 0;<br \/>  :local messageId 0;<\/p>\n<p>  :local parse do={<br \/>   :local startLoc ([:find $content $variable -1] + [:len $variable] + 2);<br \/>   :local commaLoc ([:find $content &#171;,&#187; $startLoc] \u2014 1 + 1);<br \/>   :local braceLoc ([:find $content &#171;}&#187; $startLoc] \u2014 1 + 1);<br \/>   :local endLoc $commaLoc;<br \/>   :local startSymbol [:pick $content $startLoc]<br \/>   :if ($braceLoc != 0 and ($commaLoc = 0 or $braceLoc &lt; $commaLoc)) do={<br \/>   :set endLoc $braceLoc;<br \/>   };<br \/>   :if ($startSymbol = &#171;{&#171;) do={<br \/>   :set endLoc ($braceLoc + 1);<br \/>   };<br \/>   :if ($quotas = true) do={<br \/>   :set startLoc ($startLoc + 1);<br \/>   :set endLoc ($endLoc \u2014 1);<br \/>   }<br \/>   :if ($endLoc &lt; $startLoc) do={<br \/>   :set endLoc ($startLoc + 1);<br \/>   };<br \/>   :local message [:pick $content $startLoc $endLoc]<br \/>   #:log info $message;<br \/>   :return $message;<br \/>  }<\/p>\n<p>  :while ( true ) do={<br \/>   :do {<br \/>   #:log info \u00ab<a href=\"https:\/\/api.telegram.org\/\" rel=\"nofollow\">api.telegram.org<\/a>$botID\/getUpdates\\?offset=$messageId&amp;limit=1&amp;allowed_updates=message&amp;timeout=60\u00bb;<br \/>   :tool fetch url=(\u00ab<a href=\"https:\/\/api.telegram.org\/\" rel=\"nofollow\">api.telegram.org<\/a>$botID\/getUpdates\\?offset=$messageId&amp;limit=1&amp;allowed_updates=message&amp;timeout=60\u00bb) dst-path=\u00abgetUpdates\u00bb;<br \/>   :local content [\/file get [\/file find name=getUpdates] contents];<br \/>   #:log info $content;<br \/>   :if ([:len $content] &gt; 30) do={<br \/>   :set messageId ([$parse content=$content variable=\u00abupdate_id\u00bb] + 1)<br \/>   :local message [$parse content=$content variable=\u00abtext\u00bb quotas=true]<br \/>   :local chat [$parse content=$content variable=\u00abchat\u00bb]<br \/>   :local chatId [$parse content=$chat variable=\u00abid\u00bb] <\/p>\n<p>   :if (($chatId = $myChatID) and ([\/system script find name=$message] != &#171;&#187;)) do={<br \/>   :system script run $message;<br \/>   } else={<br \/>   :tool fetch url=(\u00ab<a href=\"https:\/\/api.telegram.org\/\" rel=\"nofollow\">api.telegram.org<\/a>$botID\/sendmessage\\?chat_id=$chatId&amp;text=$mtIdentity: Unknown command: $message\u00bb) keep-result=no<br \/>   }<br \/>   }<br \/>   } on-error={}<br \/>  };  <\/div>\n<\/div>\n<p>  \u0417\u0430 \u043f\u0430\u0440\u0443 \u043b\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u044b\u043b \u0432\u044b\u044f\u0432\u043b\u0435\u043d \u0431\u0430\u0433, \u043f\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0441\u043b\u0430\u0431\u0435\u043d\u044c\u043a\u0438\u0435 Mikrotik \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u044b\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043e\u043a.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u0438\u0445 \u0446\u0435\u043b\u0435\u0439 \u043d\u0430\u043a\u0438\u0434\u0430\u043b \u043a\u043e\u0441\u0442\u044b\u043b\u044c WatchDog. \u0442\u0443\u0442 \u043c\u0435\u043d\u044f\u0435\u043c \u0438\u043c\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043d\u0430 \u0442\u043e \u043a\u0430\u043a\u043e\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432\u044b\u0448\u0435. \u0438 \u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 5 \u043c\u0438\u043d\u0443\u0442. \u041a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442 \u043d\u0430\u0448\u0430 \u00ab\u0441\u043c\u043e\u0442\u0440\u044f\u0449\u0430\u044f \u0441\u043e\u0431\u0430\u043a\u0430\u00bb \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0435\u0433\u043e.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">WatchDogT.me<\/b><\/p>\n<div class=\"spoiler_text\">:global scriptname \u00abt.me\u00bb<br \/>  :if ([:len [\/system script job find script=$\u00abscriptname\u00bb]] &gt; 0) do={<br \/>  :log info &#171;$scriptname Already Running \u2014 killing old script before continuing&#187;<br \/>  :foreach counter in=[\/system script job find script=$\u00abscriptname\u00bb] do={<br \/>  \/system script job remove $counter<br \/>  }<br \/>  }<br \/>  \/system script run $scriptname  <\/div>\n<\/div>\n<p>  \u041d\u0443 \u0438 \u043d\u0430 \u0434\u0435\u0441\u0435\u0440\u0442, \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u0437\u044f\u0442 \u0441 \u0444\u043e\u0440\u0443\u043c\u0430 Mikrotik.<br \/>  \u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0430\u0436\u043d\u044b\u0435 \u0442\u043e\u043f\u0438\u043a\u0438 \u0438\u0437 \u043b\u043e\u0433\u0430 \u043d\u0430\u043c \u0432 \u0442\u0435\u043b\u0435\u0433\u0443.<br \/>  \u0417\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 schedule \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442, \u043c\u0435\u043d\u044f\u0435\u043c BotID \u0438 ChatID \u043d\u0430 \u0441\u0432\u043e\u0438. <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Notify-log<\/b><\/p>\n<div class=\"spoiler_text\">:global lastTime<br \/>  :global output<br \/>  :global mtIdentity [\/system identity get name];<br \/>  :global botID \u00abbotXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXX\u00bb;<br \/>  :global myChatID \u00abYYYYYY\u00bb;<\/p>\n<p>  :local LogGet [ :toarray [ \/log find topics~\u00abcritical\u00bb || message~\u00ablogin failure\u00bb || message~&#187;[Ff]ailure&#187; ] ];<br \/>  :local LogtLineCount [ :len $LogGet ];<br \/>  if ($LogtLineCount &gt; 0) do={<br \/>   :local currentTime &#171;$[ \/log get [ :pick $LogGet ($LogtLineCount -1) ] time ]&#187;;<br \/>   :if ([:len $currentTime] = 10 ) do={<br \/>   :set currentTime [ :pick $currentTime 0 10 ];<br \/>   }<br \/>   :set output &#171;$currentTime \u2014 $[\/log get [ :pick $LogGet ($LogtLineCount-1) ] message ]&#187;;<br \/>   :if (([:len $lastTime] &lt; 1) || (([:len $lastTime] &gt; 0) &amp;&amp; ($lastTime != $currentTime))) do={<br \/>   :set lastTime $currentTime;<br \/>   :tool fetch url=(\u00ab<a href=\"https:\/\/api.telegram.org\/\" rel=\"nofollow\">api.telegram.org<\/a>$botID\/sendmessage\\?chat_id=$myChatID&amp;text=\\\u00bb$mtIdentity\\&#187;: $output&#187;) keep-result=no<br \/>   }<br \/>  }  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bac\/cd2\/5eb\/baccd25eb9939ef60e9a6b42cf036c44.jpg\" alt=\"image\"><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/482802\/\"> https:\/\/habr.com\/ru\/post\/482802\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/482802\/\">\u0412\u0441\u0435\u0445 \u0441 \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u043c \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u043e\u043c. \u0414\u0430\u043d\u043d\u0430\u044f \u0442\u0435\u043c\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u043b\u0443\u0447\u0448\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043f\u0438\u0441\u0430\u043b \u0432 \u0434\u0430\u043b\u0435\u043a\u043e\u043c 2016 \u0442\u0443\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/314108\/\">habr.com\/ru\/post\/314108<\/a>.<\/p>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0441\u044f, \u0441 \u0442\u043e\u0439 \u043b\u0438\u0448\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043c\u0433\u043d\u043e\u0432\u0435\u043d\u043d\u043e \u0431\u0435\u0437 \u0437\u0430\u0434\u0435\u0440\u0436\u0435\u043a.<\/p>\n<p>  \u0417\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0432 Mikrotik, \u043c\u0435\u043d\u044f\u0435\u043c BotID \u0438 ChatID \u043d\u0430 \u0441\u0432\u043e\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430 \u043d\u0435\u0433\u043e schedule. \u0421\u0442\u0430\u0432\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u00abStart Time\u00bb \u043d\u0430 startup (\u0417\u0430\u043f\u0443\u0441\u043a \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.)<br \/>  \u00abInterval\u00bb: 00:00:00<br \/>  \u0412 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0441\u0435 \u043a\u0430\u043a \u0438 \u0431\u044b\u043b\u043e. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296731","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296731","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296731"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296731\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296731"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296731"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296731"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}