kowalski/bot.js

28 lines
748 B
JavaScript
Raw Normal View History

2024-07-24 22:39:27 -03:00
const { Telegraf } = require('telegraf');
2024-07-24 23:16:39 -03:00
const Config = require('./props/config.json');
const { isOnSpamWatch } = require('./plugins/lib-spamwatch/spamwatch.js');
2024-07-24 22:39:27 -03:00
2024-07-24 23:16:39 -03:00
const bot = new Telegraf(Config.botToken);
2024-07-24 22:39:27 -03:00
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, isOnSpamWatch);
}
2024-07-24 22:39:27 -03:00
});
};
loadCommands();
bot.launch().then(() => {
console.log('Bot está rodando...');
});
process.once('SIGINT', () => bot.stop('SIGINT'));
process.once('SIGTERM', () => bot.stop('SIGTERM'));