mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-12-15 09:49:54 +03:00
chore(release): v2.0.0
This commit is contained in:
45
website/versioned_docs/version-2.0.0/telegraf-methods.md
Normal file
45
website/versioned_docs/version-2.0.0/telegraf-methods.md
Normal file
@@ -0,0 +1,45 @@
|
||||
---
|
||||
id: telegraf-methods
|
||||
title: Telegraf methods
|
||||
sidebar_label: Telegraf methods
|
||||
slug: /telegraf-methods
|
||||
---
|
||||
|
||||
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.
|
||||
|
||||
Now let's try simple example:
|
||||
|
||||
```typescript title="src/app.update.ts"
|
||||
import {
|
||||
Update,
|
||||
Ctx,
|
||||
Start,
|
||||
Help,
|
||||
On,
|
||||
Hears,
|
||||
} from 'nestjs-telegraf';
|
||||
import { TelegrafContext } from './common/interfaces/telegraf-context.interface.ts';
|
||||
|
||||
@Update()
|
||||
export class AppUpdate {
|
||||
@Start()
|
||||
async start(@Ctx() ctx: TelegrafContext) {
|
||||
await ctx.reply('Welcome');
|
||||
}
|
||||
|
||||
@Help()
|
||||
async help(@Ctx() ctx: TelegrafContext) {
|
||||
await ctx.reply('Send me a sticker');
|
||||
}
|
||||
|
||||
@On('sticker')
|
||||
async on(@Ctx() ctx: TelegrafContext) {
|
||||
await ctx.reply('👍');
|
||||
}
|
||||
|
||||
@Hears('hi')
|
||||
async hears(@Ctx() ctx: TelegrafContext) {
|
||||
await ctx.reply('Hey there');
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user