diff --git a/packages/testkit/src/mock-telegram.ts b/packages/testkit/src/mock-telegram.ts index 27d12638..61a7bb33 100644 --- a/packages/testkit/src/mock-telegram.ts +++ b/packages/testkit/src/mock-telegram.ts @@ -116,12 +116,11 @@ export class MockTelegram { return { ok: true, result: { user: this.bot, status: c.bot, ...(c.bot === "administrator" ? { can_post_messages: c.canPost } : {}) } }; } case "sendMessage": { - // Channels (-100…): the bot must be an admin that may post. - if (String(p.chat_id).startsWith("-100")) { - const c = this.channels.get(Number(p.chat_id)); - if (!c || c.bot === "left") return { ok: false, error_code: 400, description: "Bad Request: chat not found" }; - if (c.bot !== "administrator" || !c.canPost) return { ok: false, error_code: 403, description: "Forbidden: bot is not a member of the channel chat" }; - } + // Channels added with addChannel: the bot must be an admin that may post. Other «-100…» + // ids are supergroups (PEP-62) and accept messages as before. + const ch = this.channels.get(Number(p.chat_id)); + if (ch && ch.bot === "left") return { ok: false, error_code: 400, description: "Bad Request: chat not found" }; + if (ch && (ch.bot !== "administrator" || !ch.canPost)) return { ok: false, error_code: 403, description: "Forbidden: bot is not a member of the channel chat" }; const m: MockTgMessage = { message_id: this.nextMessageId++, chat_id: Number(p.chat_id),