Add support for custom telegram bot api server

pull/5668/head
Ramin Mazloomi 2025-02-28 18:34:47 +03:30
parent c7d7fdd632
commit 6a63aad4f4
3 changed files with 12 additions and 2 deletions

View File

@ -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 = {

View File

@ -33,6 +33,10 @@
<input id="message_thread_id" v-model="$parent.notification.telegramMessageThreadID" type="text" class="form-control">
<p class="form-text">{{ $t("telegramMessageThreadIDDescription") }}</p>
<label for="server_url" class="form-label">{{ $t("telegramServerUrl") }}</label>
<input id="server_url" v-model="$parent.notification.telegramServerUrl" type="text" class="form-control">
<p class="form-text">{{ $t("telegramServerUrlDescription") }}</p>
<div class="form-check form-switch">
<input v-model="$parent.notification.telegramSendSilently" class="form-check-input" type="checkbox">
<label class="form-check-label">{{ $t("telegramSendSilently") }}</label>
@ -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`;
},
/**

View File

@ -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.",