Answer the question
In order to leave comments, you need to log in
Why doesn't mikrotik script send messages to slack?
Crawling into slack from a telegram (well, you know why), I ran into the fact that slack categorically does not want to change to Cyrillic
. Here is the script itself:
:global SlackMessage "%0ATime: [Time]%0AAddress: [Device.CustomField2]%0AIP: [Device.FirstAddress]%0APing: [Service.Status]%0A";
:global SlackChannel "channel-id";
:local messageencoded "";
:local botname "DUDE-server"
:local token "slack-token"
:local iconurl https://wiki.mikrotik.com/images/5/54/Dude-icon3.png
#replace ASCII characters with URL encoded characters
:for i from=0 to=([:len $SlackMessage] - 1) do={
:local char [:pick $SlackMessage $i]
:if ($char = " ") do={
:set $char "%20"
}
:if ($char = "-") do={
:set $char "%2D"
}
:if ($char = "#") do={
:set $char "%23"
}
:if ($char = "+") do={
:set $char "%2B"
}
:if ($char = " ") do={
:set $char "%09"
}
:if ($char = ":") do={
:set $char "%3a"
}
:set messageencoded ($messageencoded . $char)
}
/tool fetch url="https://slack.com/api/chat.postMessage?token=$token&channel=$SlackChannel&text=$messageencoded&icon_url=$iconurl&as_user=false&username=$botname";
:if ($char = "ё") do={:set $char "%D1%91"}
for every letter of our alphabet, both lowercase and uppercase. Zero sense. Answer the question
In order to leave comments, you need to log in
I'll answer myself. RouterOS >= 6.39 learned in POST. Therefore, it is possible to send notifications of interest to me through slack webhooks with the content type "application/json".
Thanks to all!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question