nestjs-telegraf
Version:
Telegraf module for NestJS
36 lines (29 loc) • 1.25 kB
Markdown
# From v1 to v2
## Remove `Telegraf` prefix
If you previously used decorators with the prefix `Telegraf` in the decorator name (such as `` or ``) replace them with the same decorators but without the prefix `Telegraf`, such as ``, ``, `` and so on.
## `` decorator
Since v2, `nestjs-telegraf` looks for all update handlers only inside individual classes, under the `` decorator.
Previously, you could declare a handler anywhere, for example:
```typescript title="src/cats/cats.provider.ts"
import { Injectable } from '@nestjs/common';
import { Command } from 'nestjs-telegraf';
export class CatsProvider {
async helpCommand(ctx: TelegrafContext) {
await ctx.reply('Meow.');
}
}
```
Now you must explicitly bind the class, for Telegram Bot Api update handlers:
```typescript {3} title="src/cats/cats.updates.ts"
import { Update, Ctx } from 'nestjs-telegraf';
export class HelpUpdate {
async helpCommand( ctx: TelegrafContext) {
await ctx.reply('Help command.');
}
}
```
Treat the `` decorator like the `` decorator, but to capture Telegram Bot Api updates.