mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: $SendTelegram: allow to override chatid
This allows to send Telegram messages to different contact or group. Use something like this: /system scheduler add name=netwatch-notify interval=1m start-time=startup \ on-event=":global TelegramChatIdOverride \"-1234\"; / system script run netwatch-notify; :set TelegramChatIdOverride;"
This commit is contained in:
parent
71ae8cb75f
commit
34db2e34db
1 changed files with 8 additions and 2 deletions
|
@ -428,16 +428,22 @@
|
||||||
:global Identity;
|
:global Identity;
|
||||||
:global TelegramTokenId;
|
:global TelegramTokenId;
|
||||||
:global TelegramChatId;
|
:global TelegramChatId;
|
||||||
|
:global TelegramChatIdOverride;
|
||||||
|
|
||||||
:global UrlEncode;
|
:global UrlEncode;
|
||||||
:global CertificateAvailable;
|
:global CertificateAvailable;
|
||||||
|
|
||||||
:if ([ :len $TelegramTokenId ] > 0 && [ :len $TelegramChatId ] > 0) do={
|
:local ChatId $TelegramChatId;
|
||||||
|
:if ([ :len $TelegramChatIdOverride ] > 0) do={
|
||||||
|
:set ChatId $TelegramChatIdOverride;
|
||||||
|
}
|
||||||
|
|
||||||
|
:if ([ :len $TelegramTokenId ] > 0 && [ :len $ChatId ] > 0) do={
|
||||||
$CertificateAvailable "Go Daddy Secure Certificate Authority - G2";
|
$CertificateAvailable "Go Daddy Secure Certificate Authority - G2";
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl output=none http-method=post \
|
/ tool fetch check-certificate=yes-without-crl output=none http-method=post \
|
||||||
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
|
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
|
||||||
http-data=("chat_id=" . $TelegramChatId . "&disable_notification=" . $Silent . \
|
http-data=("chat_id=" . $ChatId . "&disable_notification=" . $Silent . \
|
||||||
"&text=" . [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ]);
|
"&text=" . [ $UrlEncode ("[" . $Identity . "] " . $Subject . "\n\n" . $Message) ]);
|
||||||
} on-error={
|
} on-error={
|
||||||
:log warning "Failed sending telegram notification!";
|
:log warning "Failed sending telegram notification!";
|
||||||
|
|
Loading…
Reference in a new issue