start pooling only if enabled
This commit is contained in:
@ -7,27 +7,19 @@ 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 });
|
||||
let bot;
|
||||
|
||||
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);
|
||||
bot.onText(/start/, handleStartCommand);
|
||||
},
|
||||
|
||||
updateUserDetails: function (chatId, phoneNumber) {
|
||||
// Function body remains the same
|
||||
}
|
||||
Initialize: initializeBot,
|
||||
updateUserDetails: updateUserDetails
|
||||
};
|
||||
|
||||
function initializeBot() {
|
||||
if (!enabled) {
|
||||
console.log("Telegram bot is not enabled.");
|
||||
return;
|
||||
}
|
||||
bot = new TelegramBot(token, { polling: true });
|
||||
bot.on('message', handleMessage);
|
||||
bot.on('new_chat_members', handleNewChatMembers);
|
||||
bot.on('contact', handleContact);
|
||||
|
Reference in New Issue
Block a user