Logging system added
This commit is contained in:
parent
784a463e8e
commit
945182329e
2 changed files with 48 additions and 7 deletions
14
src/main.js
14
src/main.js
|
@ -1,18 +1,18 @@
|
|||
const TelegramBot = require('node-telegram-bot-api');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const token = process.env.TGBOT_TOKEN; // config.env
|
||||
const logMessage = require('./logger');
|
||||
const token = process.env.TGBOT_TOKEN;
|
||||
const bot = new TelegramBot(token, { polling: true });
|
||||
|
||||
const commandsPath = path.join(__dirname, 'commands')
|
||||
const commandsPath = path.join(__dirname, 'commands');
|
||||
const commandHandlers = {};
|
||||
|
||||
// load all commands
|
||||
fs.readdirSync(commandsPath).forEach(file => {
|
||||
const command = `/${path.parse(file).name}`;
|
||||
const handler = require(path.join(commandsPath,file));
|
||||
const handler = require(path.join(commandsPath, file));
|
||||
commandHandlers[command] = handler;
|
||||
})
|
||||
});
|
||||
|
||||
bot.on('message', (msg) => {
|
||||
const messageText = msg.text;
|
||||
|
@ -25,5 +25,5 @@ bot.on('polling_error', (error) => {
|
|||
console.error('Polling error:', error);
|
||||
});
|
||||
|
||||
const date = Date();
|
||||
console.log(`INFO: Lynx started at: \n• ${date}\n`)
|
||||
const date = new Date().toString();
|
||||
console.log(`INFO: Lynx started\n`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue