Download src/modules/telegram/telegram.controller.ts from shizoki/Lovia: direct link, hf CLI and curl.
- Browser
- Download file 672 Bytes
-
https://huggingface.co/spaces/shizoki/Lovia/resolve/main/src/modules/telegram/telegram.controller.ts
- Command line
-
hf download hf://spaces/shizoki/Lovia/src/modules/telegram/telegram.controller.ts
-
curl -L -o telegram.controller.ts https://huggingface.co/spaces/shizoki/Lovia/resolve/main/src/modules/telegram/telegram.controller.ts
672 Bytes
| import { Body, Controller, ForbiddenException, Headers, Post } from '@nestjs/common'; | |
| import { TelegramService } from './telegram.service'; | |
| ('telegram') | |
| export class TelegramController { | |
| constructor(private readonly telegramService: TelegramService) {} | |
| ('webhook') | |
| handleWebhook( | |
| ('x-telegram-bot-api-secret-token') secretToken: string | undefined, | |
| () update: Record<string, unknown> | |
| ) { | |
| if (!this.telegramService.isValidWebhookSecret(secretToken)) { | |
| throw new ForbiddenException('Invalid Telegram webhook secret token'); | |
| } | |
| this.telegramService.processWebhookUpdate(update); | |
| return { ok: true }; | |
| } | |
| } | |