mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-08-04 02:04:45 +02:00
mod/notification-telegram: support sending to group's topic...
... when a group has enabled the "Topics" feature.
This commit is contained in:
parent
cad104879c
commit
a22b62f588
3 changed files with 11 additions and 2 deletions
|
@ -58,6 +58,9 @@ Sending notifications to a group is possible as well. Add your bot and the
|
|||
*GetIDs Bot* to a group, then use the group's id (which starts with a dash)
|
||||
for `TelegramChatId`. Then remove *GetIDs Bot* from group.
|
||||
|
||||
Groups can enable the `Topics` feature. Use `TelegramThreadId` to send to a
|
||||
specific topic in a group.
|
||||
|
||||
Usage and invocation
|
||||
--------------------
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
:global TelegramChatId "";
|
||||
#:global TelegramTokenId "123456:ABCDEF-GHI";
|
||||
#:global TelegramChatId "12345678";
|
||||
# Use this to send notifications to a specific topic in group.
|
||||
:global TelegramThreadId "";
|
||||
# Using telegram-chat you have to define trusted chat ids (not group ids!)
|
||||
# or user names. Groups allow to chat with devices simultaneously.
|
||||
#:global TelegramChatIdsTrusted {
|
||||
|
|
|
@ -68,6 +68,8 @@
|
|||
:global TelegramChatIdOverride;
|
||||
:global TelegramMessageIDs;
|
||||
:global TelegramQueue;
|
||||
:global TelegramThreadId;
|
||||
:global TelegramThreadIdOverride;
|
||||
:global TelegramTokenId;
|
||||
:global TelegramTokenIdOverride;
|
||||
|
||||
|
@ -108,6 +110,8 @@
|
|||
|
||||
:local ChatId [ $EitherOr ($Notification->"chatid") \
|
||||
[ $EitherOr ($TelegramChatIdOverride->($Notification->"origin")) $TelegramChatId ] ];
|
||||
:local ThreadId [ $EitherOr ($Notification->"threadid") \
|
||||
[ $EitherOr ($TelegramThreadIdOverride->($Notification->"origin")) $TelegramThreadId ] ];
|
||||
:local TokenId [ $EitherOr ($TelegramTokenIdOverride->($Notification->"origin")) $TelegramTokenId ];
|
||||
|
||||
:if ([ :len $TokenId ] = 0 || [ :len $ChatId ] = 0) do={
|
||||
|
@ -143,8 +147,8 @@
|
|||
}
|
||||
|
||||
:local HTTPData ("chat_id=" . $ChatId . "&disable_notification=" . ($Notification->"silent") . \
|
||||
"&reply_to_message_id=" . ($Notification->"replyto") . "&disable_web_page_preview=true" . \
|
||||
"&parse_mode=MarkdownV2");
|
||||
"&reply_to_message_id=" . ($Notification->"replyto") . "&message_thread_id=" . $ThreadId . \
|
||||
"&disable_web_page_preview=true&parse_mode=MarkdownV2");
|
||||
:do {
|
||||
:if ([ $CertificateAvailable "Go Daddy Root Certificate Authority - G2" ] = false) do={
|
||||
$LogPrint warning $0 ("Downloading required certificate failed.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue