import type { ChannelOutboundAdapter } from "openclaw/plugin-sdk"; import { getQiaoqiaoRuntime } from "./runtime.js"; import { sendMessageQiaoqiao } from "./send.js"; export const qiaoqiaoOutbound: ChannelOutboundAdapter = { deliveryMode: "direct", chunker: (text, limit) => getQiaoqiaoRuntime().channel.text.chunkMarkdownText(text, limit), chunkerMode: "markdown", textChunkLimit: 4000, sendText: async ({ cfg, to, text, accountId }) => { console.log("[Qiaoqiao Outbound] sendText:", { to, text, accountId }); const result = await sendMessageQiaoqiao({ cfg, to, text, accountId }); return { channel: "qiaoqiao", ...result }; }, sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, accountId }) => { console.log("[Qiaoqiao Outbound] sendMedia:", { to, text, mediaUrl, accountId }); // Send text first if provided if (text?.trim()) { await sendMessageQiaoqiao({ cfg, to, text, accountId }); } // 处理媒体 - 目前只发送链接 if (mediaUrl) { try { // TODO: 实现媒体上传 console.log("[Qiaoqiao Outbound] Media upload not implemented, sending as link"); const fallbackText = `📎 ${mediaUrl}`; const result = await sendMessageQiaoqiao({ cfg, to, text: fallbackText, accountId }); return { channel: "qiaoqiao", ...result }; } catch (err) { console.error(`[qiaoqiao] sendMedia failed:`, err); const fallbackText = `📎 ${mediaUrl}`; const result = await sendMessageQiaoqiao({ cfg, to, text: fallbackText, accountId }); return { channel: "qiaoqiao", ...result }; } } // No media URL, just return text result const result = await sendMessageQiaoqiao({ cfg, to, text: text ?? "", accountId }); return { channel: "qiaoqiao", ...result }; }, };