mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-24 23:14:39 +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,
Context,
} from 'nestjs-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');
}
}