import { type Context, type NextFunction } from 'grammy'; import { config } from '../config.js'; import { createLogger } from '../utils/logger.js'; const log = createLogger('Auth'); export async function authMiddleware(ctx: Context, next: NextFunction): Promise { const userId = ctx.from?.id; if (!userId || !config.telegram.allowedUserIds.includes(userId)) { log.warn(`Unauthorized access attempt from user ${userId || 'unknown'}`); await ctx.reply('⛔ Du bist nicht autorisiert, diesen Bot zu verwenden.'); return; } await next(); }