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 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-14 20:14:40 +05:00
parent 7c721db744
commit 6066ce8763

View File

@ -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),