telegraf-decorators-ts
v1.0.2
Published
Decorators for telegraf bot library.
Readme
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
- Use
{ enableLeaveCommand: true }to automatically add/leavecommand to your scene and you can passleaveCommandNameto change the command name like cancel
