mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-18 21:40:53 +00:00
* refactor: move Telegram channel implementation to extensions/telegram/src/ Move all Telegram channel code (123 files + 10 bot/ files + 8 channel plugin files) from src/telegram/ and src/channels/plugins/*/telegram.ts to extensions/telegram/src/. Leave thin re-export shims at original locations so cross-cutting src/ imports continue to resolve. - Fix all relative import paths in moved files (../X/ -> ../../../src/X/) - Fix vi.mock paths in 60 test files - Fix inline typeof import() expressions - Update tsconfig.plugin-sdk.dts.json rootDir to "." for cross-directory DTS - Update write-plugin-sdk-entry-dts.ts for new rootDir structure - Move channel plugin files with correct path remapping * fix: support keyed telegram send deps * fix: sync telegram extension copies with latest main * fix: correct import paths and remove misplaced files in telegram extension * fix: sync outbound-adapter with main (add sendTelegramPayloadMessages) and fix delivery.test import path
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildTelegramMessageContextForTest } from "./bot-message-context.test-harness.js";
|
|
|
|
describe("buildTelegramMessageContext sender prefix", () => {
|
|
async function buildCtx(params: { messageId: number; options?: Record<string, unknown> }) {
|
|
return await buildTelegramMessageContextForTest({
|
|
message: {
|
|
message_id: params.messageId,
|
|
chat: { id: -99, type: "supergroup", title: "Dev Chat" },
|
|
date: 1700000000,
|
|
text: "hello",
|
|
from: { id: 42, first_name: "Alice" },
|
|
},
|
|
options: params.options,
|
|
});
|
|
}
|
|
|
|
it("prefixes group bodies with sender label", async () => {
|
|
const ctx = await buildCtx({ messageId: 1 });
|
|
|
|
expect(ctx).not.toBeNull();
|
|
const body = ctx?.ctxPayload?.Body ?? "";
|
|
expect(body).toContain("Alice (42): hello");
|
|
});
|
|
|
|
it("sets MessageSid from message_id", async () => {
|
|
const ctx = await buildCtx({ messageId: 12345 });
|
|
|
|
expect(ctx).not.toBeNull();
|
|
expect(ctx?.ctxPayload?.MessageSid).toBe("12345");
|
|
});
|
|
|
|
it("respects messageIdOverride option", async () => {
|
|
const ctx = await buildCtx({
|
|
messageId: 12345,
|
|
options: { messageIdOverride: "67890" },
|
|
});
|
|
|
|
expect(ctx).not.toBeNull();
|
|
expect(ctx?.ctxPayload?.MessageSid).toBe("67890");
|
|
});
|
|
});
|