customer/src/modules/content/mock-channel.ts
2026-11-15 14:58:29 +05:00

16 lines
584 B
TypeScript

import type { ChannelClient } from "./telegram.ts";
/** Мок Telegram-канала: запоминает сообщения; `failing = true` — имитирует недоступность. */
export function mockChannel(): ChannelClient & { sent: { chatId: string; text: string }[]; failing: boolean } {
const sent: { chatId: string; text: string }[] = [];
const m = {
sent,
failing: false,
async sendMessage(chatId: string, text: string) {
if (m.failing) throw new Error("mock channel down");
sent.push({ chatId, text });
},
};
return m;
}