1.0.2 • Published 1 year ago

telegraf-decorators-ts v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Telegraf-TS-Decorators

Decorators for telegraf bot library.

Usage

import "dotenv/config";
import { Context, Telegraf } from "telegraf";
import { Bot, Command, ClassToBot, Event } from "../src";

@Bot({
    token: process.env.BOT_TOKEN as string
})
class DevBot {
    @Command('ping')
    async ping(ctx: Context) {
        return await ctx.reply('pong');
    }

    @Event('message')
    async message(ctx: Context) {
        return await ctx.reply('I don`t know what to do with this message');
    }
}

let bot = ClassToBot(DevBot);
bot.launch();

Cheat sheet for features 1. Use { enableLeaveCommand: true } to automatically add /leave command to your scene and you can pass leaveCommandName to change the command name like cancel

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago