惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
量子位
美团技术团队
大猫的无限游戏
大猫的无限游戏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Last Week in AI
Last Week in AI
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
有赞技术团队
有赞技术团队
月光博客
月光博客

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: share qqbot media path decoding · openclaw/open...
vincentkoc · 2026-05-29 · via Recent Commits to openclaw:main

@@ -34,15 +34,16 @@ export {

3434

} from "./outbound-media-send.js";

35353636

import type { GatewayAccount } from "../types.js";

37+

import type { EngineLogger } from "../types.js";

3738

import { formatErrorMessage } from "../utils/format.js";

3839

import { debugError, debugLog, debugWarn } from "../utils/log.js";

3940

import { normalizeMediaTags } from "../utils/media-tags.js";

4041

import { decodeCronPayload } from "../utils/payload.js";

41-

import { normalizePath } from "../utils/platform.js";

4242

import {

4343

normalizeLowercaseStringOrEmpty,

4444

normalizeOptionalString,

4545

} from "../utils/string-normalize.js";

46+

import { decodeMediaPath } from "./decode-media-path.js";

4647

import {

4748

isImageFile as coreIsImageFile,

4849

isVideoFile as coreIsVideoFile,

@@ -77,6 +78,11 @@ import {

77787879

const isImageFile = coreIsImageFile;

7980

const isVideoFile = coreIsVideoFile;

81+

const mediaPathDecodeLog = {

82+

info: (message: string) => debugLog(`[qqbot] sendText: ${message}`),

83+

error: (message: string) => debugError(`[qqbot] sendText: ${message}`),

84+

debug: (message: string) => debugLog(`[qqbot] sendText: ${message}`),

85+

} satisfies EngineLogger;

80868187

/**

8288

* Send text, optionally falling back from passive reply mode to proactive mode.

@@ -155,52 +161,10 @@ export async function sendText(ctx: OutboundContext): Promise<OutboundResult> {

155161156162

const tagName = normalizeLowercaseStringOrEmpty(match[1]);

157163158-

let mediaPath = normalizeOptionalString(match[2]) ?? "";

159-

if (mediaPath.startsWith("MEDIA:")) {

160-

mediaPath = mediaPath.slice("MEDIA:".length);

161-

}

162-

mediaPath = normalizePath(mediaPath);

163-164-

mediaPath = mediaPath.replace(/\\\\/g, "\\");

165-166-

const isWinLocal = /^[a-zA-Z]:[\\/]/.test(mediaPath) || mediaPath.startsWith("\\\\");

167-

try {

168-

const hasOctal = /\\[0-7]{1,3}/.test(mediaPath);

169-

const hasNonASCII = /[\u0080-\u00FF]/.test(mediaPath);

170-171-

if (!isWinLocal && (hasOctal || hasNonASCII)) {

172-

debugLog(`[qqbot] sendText: Decoding path with mixed encoding: ${mediaPath}`);

173-174-

let decoded = mediaPath.replace(/\\([0-7]{1,3})/g, (_: string, octal: string) => {

175-

return String.fromCharCode(Number.parseInt(octal, 8));

176-

});

177-178-

const bytes: number[] = [];

179-

for (let i = 0; i < decoded.length; i++) {

180-

const code = decoded.charCodeAt(i);

181-

if (code <= 0xff) {

182-

bytes.push(code);

183-

} else {

184-

const charBytes = Buffer.from(decoded[i], "utf8");

185-

bytes.push(...charBytes);

186-

}

187-

}

188-189-

const buffer = Buffer.from(bytes);

190-

const utf8Decoded = buffer.toString("utf8");

191-192-

if (!utf8Decoded.includes("\uFFFD") || utf8Decoded.length < decoded.length) {

193-

mediaPath = utf8Decoded;

194-

debugLog(`[qqbot] sendText: Successfully decoded path: ${mediaPath}`);

195-

}

196-

}

197-

} catch (decodeErr) {

198-

debugError(

199-

`[qqbot] sendText: Path decode error: ${

200-

decodeErr instanceof Error ? decodeErr.message : JSON.stringify(decodeErr)

201-

}`,

202-

);

203-

}

164+

const mediaPath = decodeMediaPath(

165+

normalizeOptionalString(match[2]) ?? "",

166+

mediaPathDecodeLog,

167+

);

204168205169

if (mediaPath) {

206170

if (tagName === "qqmedia") {