mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-27 08:18:08 +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 @Hears
, @On
, @Action
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 {
Start,
Help,
On,
Hears,
} from 'nestjs-telegraf';
import { Context } from 'telegraf';
@Injectable()
export class AppService {
@Start()
start(ctx: Context) {
ctx.reply('Welcome');
}
@Help()
help(ctx: Context) {
ctx.reply('Send me a sticker');
}
@On('sticker')
on(ctx: Context) {
ctx.reply('👍');
}
@Hears('hi')
hears(ctx: Context) {
ctx.reply('Hey there');
}
}