mirror of
https://github.com/eworm-de/routeros-scripts
synced 2024-05-14 08:04:19 +00:00
global-functions: support sending silent telegram notifications
This commit is contained in:
parent
d457421e1e
commit
06b93ca6c2
1 changed files with 6 additions and 4 deletions
|
@ -118,6 +118,7 @@
|
||||||
:global SendTelegram do={
|
:global SendTelegram do={
|
||||||
:local Subject [ :tostr $1 ];
|
:local Subject [ :tostr $1 ];
|
||||||
:local Message [ :tostr $2 ];
|
:local Message [ :tostr $2 ];
|
||||||
|
:local Silent [ :tostr $3 ];
|
||||||
|
|
||||||
:global Identity;
|
:global Identity;
|
||||||
:global TelegramTokenId;
|
:global TelegramTokenId;
|
||||||
|
@ -131,8 +132,8 @@
|
||||||
:do {
|
:do {
|
||||||
/ tool fetch check-certificate=yes-without-crl keep-result=no http-method=post \
|
/ tool fetch check-certificate=yes-without-crl keep-result=no http-method=post \
|
||||||
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
|
("https://api.telegram.org/bot" . $TelegramTokenId . "/sendMessage") \
|
||||||
http-data=("chat_id=" . $TelegramChatId . "&text=" . \
|
http-data=("chat_id=" . $TelegramChatId . "&disable_notification=" . $Silent . \
|
||||||
[ $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!";
|
||||||
}
|
}
|
||||||
|
@ -140,17 +141,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
# send notification via e-mail and telegram
|
# send notification via e-mail and telegram
|
||||||
# Note that attachment is ignored for telegram!
|
# Note that attachment is ignored for telegram, silent is ignored for e-mail!
|
||||||
:global SendNotification do={
|
:global SendNotification do={
|
||||||
:local Subject [ :tostr $1 ];
|
:local Subject [ :tostr $1 ];
|
||||||
:local Message [ :tostr $2 ];
|
:local Message [ :tostr $2 ];
|
||||||
:local Attach [ :tostr $3 ];
|
:local Attach [ :tostr $3 ];
|
||||||
|
:local Silent [ :tostr $4 ];
|
||||||
|
|
||||||
:global SendEMail;
|
:global SendEMail;
|
||||||
:global SendTelegram;
|
:global SendTelegram;
|
||||||
|
|
||||||
$SendEMail $Subject $Message $Attach;
|
$SendEMail $Subject $Message $Attach;
|
||||||
$SendTelegram $Subject $Message;
|
$SendTelegram $Subject $Message $Silent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue