refactoring
This commit is contained in:
17
src/context/bot.js
Normal file
17
src/context/bot.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import TelegramBot from "node-telegram-bot-api";
|
||||
import config from "../config/config.js";
|
||||
|
||||
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();
|
||||
|
||||
export default bot;
|
||||
Reference in New Issue
Block a user