@ -14,8 +14,6 @@ const REST = require('@discordjs/rest').REST;
const API = require ( '@discordjs/core' ) . API ;
const EmbedBuilder = require ( '@discordjs/builders' ) . EmbedBuilder ;
const debugMode = process . env . YTDL _MODE === 'debug' ;
const NOTIFICATION _TYPE _TO _TITLE = {
task _finished : 'Task finished' ,
download _complete : 'Download complete' ,
@ -160,7 +158,7 @@ config_api.config_updated.subscribe(change => {
const bot _token = config _api . getConfigItem ( 'ytdl_telegram_bot_token' ) ;
if ( ! use _telegram _api || ! bot _token ) return ;
if ( ! change ) return ;
if ( change [ 'key' ] === 'ytdl_use_telegram_API' || change [ 'key' ] === 'ytdl_telegram_bot_token' ) {
if ( change [ 'key' ] === 'ytdl_use_telegram_API' || change [ 'key' ] === 'ytdl_telegram_bot_token' || change [ 'key' ] === 'ytdl_telegram_webhook_proxy' ) {
logger . debug ( 'Telegram bot setting up' ) ;
setupTelegramBot ( ) ;
}
@ -170,9 +168,10 @@ async function setupTelegramBot() {
const use _telegram _api = config _api . getConfigItem ( 'ytdl_use_telegram_API' ) ;
const bot _token = config _api . getConfigItem ( 'ytdl_telegram_bot_token' ) ;
if ( ! use _telegram _api || ! bot _token ) return ;
telegram _bot = new TelegramBotAPI ( bot _token ) ;
const webhook _url = ` ${ utils . getBaseURL ( ) } /api/telegramRequest ` ;
const webhook _proxy = config _api . getConfigItem ( 'ytdl_telegram_webhook_proxy' ) ;
const webhook _url = webhook _proxy ? webhook _proxy : ` ${ utils . getBaseURL ( ) } /api/telegramRequest ` ;
telegram _bot . setWebHook ( webhook _url ) ;
}