mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-29 17:18:10 +03:00
1.1 KiB
1.1 KiB
id | title | sidebar_label | slug |
---|---|---|---|
telegraf-methods | Telegraf methods | Telegraf methods | /telegraf-methods |
Each Telegraf instance method described here has own decorator in nestjs-telegraf
package. The name of the decorator corresponds to the name of the Telegraf method. For example @TelegrafHears
, @TelegrafOn
, @TelegrafAction
and so on.
Now let's try to repeat the example from the Telegraf documentation page.
/* app.service.ts */
import { Injectable } from '@nestjs/common';
import {
TelegrafStart,
TelegrafHelp,
TelegrafOn,
TelegrafHears,
Context,
} from 'nestjs-telegraf';
@Injectable()
export class AppService {
@TelegrafStart()
start(ctx: Context) {
ctx.reply('Welcome');
}
@TelegrafHelp()
help(ctx: Context) {
ctx.reply('Send me a sticker');
}
@TelegrafOn('sticker')
on(ctx: Context) {
ctx.reply('👍');
}
@TelegrafHears('hi')
hears(ctx: Context) {
ctx.reply('Hey there');
}
}