2023-07-24 16:02:21 +03:00
# Telegraf methods
2021-02-14 23:59:26 +03:00
Each Telegraf instance method has own decorator in `nestjs-telegraf` package. The name of the decorator corresponds to the name of the Telegraf method. For example [`@Hears` ](https://telegraf.js.org/classes/telegraf.html#hears ), [`@On` ](https://telegraf.js.org/classes/telegraf.html#on ), [`@Action` ](https://telegraf.js.org/classes/telegraf.html#action ) and so on.
2020-09-09 23:40:23 +03:00
2021-02-14 23:59:26 +03:00
Now let's try simple example:
2020-09-09 23:40:23 +03:00
2021-02-14 23:59:26 +03:00
```typescript title="src/app.update.ts"
2020-09-09 23:40:23 +03:00
import {
2021-02-14 23:59:26 +03:00
Update,
Ctx,
2020-09-09 23:40:23 +03:00
Start,
Help,
On,
Hears,
} from 'nestjs-telegraf';
2021-02-14 23:59:26 +03:00
import { TelegrafContext } from './common/interfaces/telegraf-context.interface.ts';
2020-09-09 23:40:23 +03:00
2021-02-14 23:59:26 +03:00
@Update ()
export class AppUpdate {
2020-09-09 23:40:23 +03:00
@Start ()
2021-02-14 23:59:26 +03:00
async start(@Ctx() ctx: TelegrafContext) {
await ctx.reply('Welcome');
2020-09-09 23:40:23 +03:00
}
@Help ()
2021-02-14 23:59:26 +03:00
async help(@Ctx() ctx: TelegrafContext) {
await ctx.reply('Send me a sticker');
2020-09-09 23:40:23 +03:00
}
@On ('sticker')
2021-02-14 23:59:26 +03:00
async on(@Ctx() ctx: TelegrafContext) {
await ctx.reply('👍');
2020-09-09 23:40:23 +03:00
}
@Hears ('hi')
2021-02-14 23:59:26 +03:00
async hears(@Ctx() ctx: TelegrafContext) {
await ctx.reply('Hey there');
2020-09-09 23:40:23 +03:00
}
}
```