import type { Context, MiddlewareFn } from 'telegraf';

export function createChatGuard(allowedIds: number[]): MiddlewareFn<Context> {
  return (ctx, next) => {
    const chatId = ctx.chat?.id;
    if (chatId === undefined || !allowedIds.includes(chatId)) {
      // Silently ignore - bot stays invisible to unauthorized chats
      return;
    }
    return next();
  };
}
