diff --git a/.env b/.env index 7e5763a..2cf2b5e 100644 --- a/.env +++ b/.env @@ -44,4 +44,5 @@ EMAIL_FROM=noreply@example.com GMAIL_EMAIL_USERNAME= GMAIL_EMAIL_APP_PASS= +TELEGRAM_BOT=false TELEGRAM_BOT_TOKEN=7050075088:AAH6VRpNCyQd9x9sW6CLm6q0q4ibUgYBfnM diff --git a/.env.development b/.env.development index 4e03747..3c82532 100644 --- a/.env.development +++ b/.env.development @@ -11,3 +11,5 @@ SSL_KEY=./certificates/localhost-key.pem SSL_CERT=./certificates/localhost.pem DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev + +TELEGRAM_BOT=true \ No newline at end of file diff --git a/src/telegram.js b/src/telegram.js index 07d0950..574ab6f 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -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);