INNER CODE UNIT · TypeScript
TelegramHandler
im4codes/imcodes · server/src/platform/handlers/telegram/index.ts:4
export class TelegramHandler implements PlatformHandler {
getCapabilities(): PlatformCapabilities {
return {
maxMessageLength: 4096,
supportsThreadedReplies: true,
supportsMarkdown: true,
supportsCodeBlocks: true,
rateLimitPerMin: 30,
requiredConfigKeys: ['botToken', 'webhookSecret'],
};
}
async verifyInbound(req: Request, config: BotConfig): Promise<boolean> {
const secret = req.headers.get('X-Telegram-Bot-Api-Secret-Token');
const expected = config.config.webhookSecret;
if (!secret || !expected) return false;
// Timing-safe comparison