From 6a63aad4f400d0b204f5539301b054bd7579f6f5 Mon Sep 17 00:00:00 2001 From: Ramin Mazloomi Date: Fri, 28 Feb 2025 18:34:47 +0330 Subject: [PATCH] Add support for custom telegram bot api server --- server/notification-providers/telegram.js | 2 +- src/components/notifications/Telegram.vue | 10 +++++++++- src/lang/en.json | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/notification-providers/telegram.js b/server/notification-providers/telegram.js index c5bbb1909..df62015f4 100644 --- a/server/notification-providers/telegram.js +++ b/server/notification-providers/telegram.js @@ -9,7 +9,7 @@ class Telegram extends NotificationProvider { */ async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { const okMsg = "Sent Successfully."; - const url = "https://api.telegram.org"; + const url = notification.telegramServerUrl ?? "https://api.telegram.org"; try { let params = { diff --git a/src/components/notifications/Telegram.vue b/src/components/notifications/Telegram.vue index a072c3ed3..3b32e3130 100644 --- a/src/components/notifications/Telegram.vue +++ b/src/components/notifications/Telegram.vue @@ -33,6 +33,10 @@

{{ $t("telegramMessageThreadIDDescription") }}

+ + +

{{ $t("telegramServerUrlDescription") }}

+
@@ -63,6 +67,9 @@ export default { components: { HiddenInput, }, + mounted() { + this.$parent.notification.telegramServerUrl ||= "https://api.telegram.org"; + }, methods: { /** * Get the URL for telegram updates @@ -70,6 +77,7 @@ export default { * @returns {string} formatted URL */ telegramGetUpdatesURL(mode = "masked") { + let serverUrl = this.$parent.notification.telegramServerUrl; let token = `<${this.$t("YOUR BOT TOKEN HERE")}>`; if (this.$parent.notification.telegramBotToken) { @@ -80,7 +88,7 @@ export default { } } - return `https://api.telegram.org/bot${token}/getUpdates`; + return `${serverUrl}/bot${token}/getUpdates`; }, /** diff --git a/src/lang/en.json b/src/lang/en.json index e215f1031..fd5edaa7a 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -423,6 +423,8 @@ "telegramProtectContentDescription": "If enabled, the bot messages in Telegram will be protected from forwarding and saving.", "supportTelegramChatID": "Support Direct Chat / Group / Channel's Chat ID", "wayToGetTelegramChatID": "You can get your chat ID by sending a message to the bot and going to this URL to view the chat_id:", + "telegramServerUrl": "(Optional) Server Url", + "telegramServerUrlDescription": "Telegram custom bot api server url. Defaults to https://api.telegram.org if empty.", "YOUR BOT TOKEN HERE": "YOUR BOT TOKEN HERE", "chatIDNotFound": "Chat ID is not found; please send a message to this bot first", "disableCloudflaredNoAuthMsg": "You are in No Auth mode, a password is not required.",