mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
27 lines
659 B
JavaScript
27 lines
659 B
JavaScript
const { Telegraf } = require('telegraf');
|
|
const Config = require('./props/config.json');
|
|
|
|
const bot = new Telegraf(Config.botToken);
|
|
|
|
const loadCommands = () => {
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const commandsPath = path.join(__dirname, 'commands');
|
|
|
|
fs.readdirSync(commandsPath).forEach((file) => {
|
|
const command = require(path.join(commandsPath, file));
|
|
if (typeof command === 'function') {
|
|
command(bot);
|
|
};
|
|
});
|
|
};
|
|
|
|
loadCommands();
|
|
|
|
bot.launch().then(() => {
|
|
console.log('Bot está rodando...');
|
|
});
|
|
|
|
process.once('SIGINT', () => bot.stop('SIGINT'));
|
|
process.once('SIGTERM', () => bot.stop('SIGTERM'));
|