don't start telegram bot if not enabled by environment

This commit is contained in:
Dobromir Popov
2024-02-28 17:15:59 +02:00
parent c1a567cad7
commit 8f48ac2633
3 changed files with 9 additions and 0 deletions

View File

@ -5,11 +5,17 @@ const TelegramBot = require('node-telegram-bot-api');
const filePath = path.join(__dirname, '../content/telegram_users.json');
const token = process.env.TELEGRAM_BOT_TOKEN;
const enabled = process.env.TELEGRAM_BOT_ENABLED === 'true';
const bot = new TelegramBot(token, { polling: true });
const telegramBot = {
Initialize: function () {
if (!enabled) {
console.log("Telegram bot is not enabled.");
return;
}
bot.on('message', handleMessage);
bot.on('new_chat_members', handleNewChatMembers);
bot.on('contact', handleContact);