import { Telegraf } from "telegraf" ; import HttpsProxyAgent from "https-proxy-agent" ; const proxyUrl = process . env . HTTPS_PROXY ; let telegramBot ; if ( proxyUrl ) { telegramBot = process . env . TELEGRAM_TOKEN && process . env . TELEGRAM_CHAT_ID ? new Telegraf ( process . env . TELEGRAM_TOKEN , { telegram : { agent : HttpsProxyAgent ( proxyUrl ) , } , } ) : undefined ; } else { telegramBot = process . env . TELEGRAM_TOKEN && process . env . TELEGRAM_CHAT_ID ? new Telegraf ( process . env . TELEGRAM_TOKEN ) : undefined ; } if ( telegramBot ) telegramBot . launch ( ) ; export function sendTelegramMessage ( message ) { if ( ! telegramBot ) return ; const chatString = process . env . TELEGRAM_CHAT_ID || "" ; const chats = chatString . split ( "," ) ; for ( let chatid of chats ) { telegramBot . telegram . sendMessage ( chatid . trim ( ) , message ) ; } }