refactoring
This commit is contained in:
50
src/index.js
50
src/index.js
@@ -1,18 +1,16 @@
|
||||
import TelegramBot from 'node-telegram-bot-api';
|
||||
import config from './config/config.js';
|
||||
import UserHandler from './handlers/userHandler.js';
|
||||
import UserProductHandler from './handlers/userProductHandler.js';
|
||||
import UserWalletsHandler from './handlers/userWalletsHandler.js';
|
||||
import UserLocationHandler from './handlers/userLocationHandler.js';
|
||||
import AdminHandler from './handlers/adminHandler.js';
|
||||
import AdminUserHandler from './handlers/adminUserHandler.js';
|
||||
import AdminLocationHandler from './handlers/adminLocationHandler.js';
|
||||
import AdminProductHandler from './handlers/adminProductHandler.js';
|
||||
import adminUserHandler from './handlers/adminHandlers/adminUserHandler.js';
|
||||
import ErrorHandler from './utils/errorHandler.js';
|
||||
import User from './models/User.js';
|
||||
import AdminUserLocationHandler from "./handlers/adminUserLocationHandler.js";
|
||||
import AdminDumpHandler from "./handlers/adminDumpHandler.js";
|
||||
import UserPurchaseHandler from "./handlers/userPurchaseHandler.js";
|
||||
import bot from "./context/bot.js";
|
||||
import userHandler from "./handlers/userHandlers/userHandler.js";
|
||||
import userPurchaseHandler from "./handlers/userHandlers/userPurchaseHandler.js";
|
||||
import userLocationHandler from "./handlers/userHandlers/userLocationHandler.js";
|
||||
import userProductHandler from "./handlers/userHandlers/userProductHandler.js";
|
||||
import userWalletsHandler from "./handlers/userHandlers/userWalletsHandler.js";
|
||||
import adminHandler from "./handlers/adminHandlers/adminHandler.js";
|
||||
import adminUserLocationHandler from "./handlers/adminHandlers/adminUserLocationHandler.js";
|
||||
import adminDumpHandler from "./handlers/adminHandlers/adminDumpHandler.js";
|
||||
import adminLocationHandler from "./handlers/adminHandlers/adminLocationHandler.js";
|
||||
import adminProductHandler from "./handlers/adminHandlers/adminProductHandler.js";
|
||||
|
||||
// Debug logging function
|
||||
const logDebug = (action, functionName) => {
|
||||
@@ -20,30 +18,6 @@ const logDebug = (action, functionName) => {
|
||||
console.log(`[DEBUG] Calling Function: ${functionName}`);
|
||||
};
|
||||
|
||||
const initBot = () => {
|
||||
try {
|
||||
const bot = new TelegramBot(config.BOT_TOKEN, {polling: true});
|
||||
console.log('Bot initialized successfully');
|
||||
return bot;
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize bot:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
const bot = initBot();
|
||||
const userHandler = new UserHandler(bot);
|
||||
const userProductHandler = new UserProductHandler(bot);
|
||||
const userWalletsHandler = new UserWalletsHandler(bot);
|
||||
const userLocationHandler = new UserLocationHandler(bot);
|
||||
const adminHandler = new AdminHandler(bot);
|
||||
const adminUserHandler = new AdminUserHandler(bot);
|
||||
const adminLocationHandler = new AdminLocationHandler(bot);
|
||||
const adminUserLocationHandler = new AdminUserLocationHandler(bot);
|
||||
const adminProductHandler = new AdminProductHandler(bot);
|
||||
const adminDumpHandler = new AdminDumpHandler(bot);
|
||||
const userPurchaseHandler = new UserPurchaseHandler(bot);
|
||||
|
||||
// Start command - Create user profile
|
||||
bot.onText(/\/start/, async (msg) => {
|
||||
logDebug('/start', 'handleStart');
|
||||
|
||||
Reference in New Issue
Block a user