From 6066ce8763107cd4dc437a90a3f0cb0082e8d26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=81=D0=B5=D0=BB=D1=8C?= Date: Sat, 14 Nov 2026 20:14:40 +0500 Subject: [PATCH] PEP-60: mock-telegram rejects posts only to channels added with addChannel (supergroups of PEP-62 keep working) Co-Authored-By: Claude Opus 5.5 --- packages/testkit/src/mock-telegram.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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),