Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { logToAdmin } = require('./helpers');
- class TgBotDecoratorClass {
- constructor(botToken, config) {
- bot = new Telegraf(botToken, config);
- }
- command = (commandName, commandHandler) => {
- bot.command(commandName, addCatch(commandHandler));
- }
- addCatch = (commandHandler) => {
- return ctx => {
- try {
- commandHandler(ctx);
- } catch(error) {
- logToAdmin(bot)(error);
- }
- }
- }
- }
- module.exports.TgBotDecorator = (botToken, config) => {
- return new TgBotDecoratorClass(botToken, config);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement