mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-12-16 02:09:53 +03:00
chore(release): v2.0.0
This commit is contained in:
44
website/versioned_docs/version-2.0.0/getting-updates.md
Normal file
44
website/versioned_docs/version-2.0.0/getting-updates.md
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
id: getting-updates
|
||||
title: Getting updates
|
||||
sidebar_label: Getting updates
|
||||
slug: getting-updates
|
||||
---
|
||||
|
||||
## Long polling
|
||||
|
||||
By default, the bot receives updates using long-polling and requires no additional action.
|
||||
|
||||
## Webhooks
|
||||
|
||||
If you want to configure a telegram bot webhook, you need to get a middleware via `getBotToken` helper in your `main.ts` file.
|
||||
|
||||
To access it, you must use the `app.get()` method, followed by the provider reference:
|
||||
```typescript
|
||||
import { getBotToken } from 'nestjs-telegraf';
|
||||
|
||||
// ...
|
||||
const bot = app.get(getBotToken());
|
||||
```
|
||||
|
||||
Now you can connect middleware:
|
||||
```typescript
|
||||
app.use(bot.webhookCallback('/secret-path'));
|
||||
```
|
||||
|
||||
The last step is to specify launchOptions in `forRoot` method:
|
||||
```typescript
|
||||
TelegrafModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
token: configService.get<string>('TELEGRAM_BOT_TOKEN'),
|
||||
launchOptions: {
|
||||
webhook: {
|
||||
domain: 'domain.tld',
|
||||
hookPath: '/secret-path',
|
||||
}
|
||||
}
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user