diff --git a/src/telegram.js b/src/telegram.js index 574ab6f..da6b4cd 100644 --- a/src/telegram.js +++ b/src/telegram.js @@ -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);