From b91fe9d96d1b8be9f6abbb241432d53fd9b61247 Mon Sep 17 00:00:00 2001 From: shyneko Date: Thu, 12 Jan 2023 15:09:05 +0200 Subject: [PATCH] Added a more telegram options such as thread id, silent notifications and forward protect --- server/notification-providers/telegram.js | 17 +++++++++--- src/components/notifications/Telegram.vue | 34 +++++++++++++++++++++++ src/languages/en.js | 6 ++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/server/notification-providers/telegram.js b/server/notification-providers/telegram.js index 2b057622..9c8f5750 100644 --- a/server/notification-providers/telegram.js +++ b/server/notification-providers/telegram.js @@ -9,11 +9,20 @@ class Telegram extends NotificationProvider { let okMsg = "Sent Successfully."; try { + const paramsObj = + { + chat_id: notification.telegramChatID, + text: msg, + disable_notification: notification.telegramSilentNotification ?? false, + protect_content: notification.telegramProtectContent ?? false, + + }; + // if telegramChatThread specified, then add it to paramsObj + if (notification.telegramChatThread && notification.telegramChatThread.length > 0) { + paramsObj.message_thread_id = notification.telegramChatThread; + } await axios.get(`https://api.telegram.org/bot${notification.telegramBotToken}/sendMessage`, { - params: { - chat_id: notification.telegramChatID, - text: msg, - }, + params: paramsObj }); return okMsg; diff --git a/src/components/notifications/Telegram.vue b/src/components/notifications/Telegram.vue index 9daf31ac..9b373b99 100644 --- a/src/components/notifications/Telegram.vue +++ b/src/components/notifications/Telegram.vue @@ -29,6 +29,40 @@

+ +
+ + +
+ +
+ +
+ {{ $t("Thread ID Description") }} +
+
+ +
+
+ + +
+ +
+ {{ $t("Silent Notification Description") }} +
+
+ +
+
+ + +
+ +
+ {{ $t("Protect Forwarding Description") }} +
+