



























@@ -130,6 +130,71 @@ describe("resolveTelegramInboundBody", () => {
130130expect(result?.bodyText).toBe("<media:document> (2 attachments)");
131131});
132132133+it("lets catch-all mention patterns activate captionless group photos", async () => {
134+const logger = { info: vi.fn() };
135+136+const result = await resolveTelegramBody({
137+cfg: {
138+channels: { telegram: {} },
139+messages: { groupChat: { mentionPatterns: [".*"] } },
140+} as never,
141+msg: {
142+message_id: 6,
143+date: 1_700_000_006,
144+chat: { id: -1001234567890, type: "supergroup", title: "Test Group" },
145+from: { id: 46, first_name: "Eve" },
146+photo: [{ file_id: "photo-4", file_unique_id: "photo-u4", width: 120, height: 80 }],
147+entities: [],
148+} as never,
149+allMedia: [{ path: "/tmp/photo.webp", contentType: "image/webp" }],
150+isGroup: true,
151+chatId: -1001234567890,
152+senderId: "46",
153+senderUsername: "",
154+groupConfig: { requireMention: true } as never,
155+requireMention: true,
156+ logger,
157+});
158+159+expect(logger.info).not.toHaveBeenCalled();
160+expect(result?.rawBody).toBe("<media:image>");
161+expect(result?.bodyText).toBe("<media:image>");
162+expect(result?.effectiveWasMentioned).toBe(true);
163+});
164+165+it("keeps captionless group photos quiet for nonmatching mention patterns", async () => {
166+const logger = { info: vi.fn() };
167+168+const result = await resolveTelegramBody({
169+cfg: {
170+channels: { telegram: {} },
171+messages: { groupChat: { mentionPatterns: ["\\bbot\\b"] } },
172+} as never,
173+msg: {
174+message_id: 7,
175+date: 1_700_000_007,
176+chat: { id: -1001234567890, type: "supergroup", title: "Test Group" },
177+from: { id: 46, first_name: "Eve" },
178+photo: [{ file_id: "photo-5", file_unique_id: "photo-u5", width: 120, height: 80 }],
179+entities: [],
180+} as never,
181+allMedia: [{ path: "/tmp/photo.webp", contentType: "image/webp" }],
182+isGroup: true,
183+chatId: -1001234567890,
184+senderId: "46",
185+senderUsername: "",
186+groupConfig: { requireMention: true } as never,
187+requireMention: true,
188+ logger,
189+});
190+191+expect(logger.info).toHaveBeenCalledWith(
192+{ chatId: -1001234567890, reason: "no-mention" },
193+"skipping group message",
194+);
195+expect(result).toBeNull();
196+});
197+133198it("does not transcribe group audio for unauthorized senders", async () => {
134199transcribeFirstAudioMock.mockReset();
135200const logger = { info: vi.fn() };
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。