don't start telegram bot if not enabled by environment
This commit is contained in:
1
.env
1
.env
@ -44,4 +44,5 @@ EMAIL_FROM=noreply@example.com
|
|||||||
GMAIL_EMAIL_USERNAME=
|
GMAIL_EMAIL_USERNAME=
|
||||||
GMAIL_EMAIL_APP_PASS=
|
GMAIL_EMAIL_APP_PASS=
|
||||||
|
|
||||||
|
TELEGRAM_BOT=false
|
||||||
TELEGRAM_BOT_TOKEN=7050075088:AAH6VRpNCyQd9x9sW6CLm6q0q4ibUgYBfnM
|
TELEGRAM_BOT_TOKEN=7050075088:AAH6VRpNCyQd9x9sW6CLm6q0q4ibUgYBfnM
|
||||||
|
@ -11,3 +11,5 @@ SSL_KEY=./certificates/localhost-key.pem
|
|||||||
SSL_CERT=./certificates/localhost.pem
|
SSL_CERT=./certificates/localhost.pem
|
||||||
|
|
||||||
DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev
|
DATABASE_URL=mysql://root:Zelen0ku4e@192.168.0.10:3306/cart_dev
|
||||||
|
|
||||||
|
TELEGRAM_BOT=true
|
@ -5,11 +5,17 @@ const TelegramBot = require('node-telegram-bot-api');
|
|||||||
|
|
||||||
const filePath = path.join(__dirname, '../content/telegram_users.json');
|
const filePath = path.join(__dirname, '../content/telegram_users.json');
|
||||||
const token = process.env.TELEGRAM_BOT_TOKEN;
|
const token = process.env.TELEGRAM_BOT_TOKEN;
|
||||||
|
const enabled = process.env.TELEGRAM_BOT_ENABLED === 'true';
|
||||||
|
|
||||||
const bot = new TelegramBot(token, { polling: true });
|
const bot = new TelegramBot(token, { polling: true });
|
||||||
|
|
||||||
const telegramBot = {
|
const telegramBot = {
|
||||||
Initialize: function () {
|
Initialize: function () {
|
||||||
|
if (!enabled) {
|
||||||
|
console.log("Telegram bot is not enabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bot.on('message', handleMessage);
|
bot.on('message', handleMessage);
|
||||||
bot.on('new_chat_members', handleNewChatMembers);
|
bot.on('new_chat_members', handleNewChatMembers);
|
||||||
bot.on('contact', handleContact);
|
bot.on('contact', handleContact);
|
||||||
|
Reference in New Issue
Block a user