Skip to content

Commit 3975f27

Browse files
AliceLJYclaude
andcommitted
fix: expand sendable file extensions — add txt, md, json, py, sh, zip etc
.txt was not in the extension whitelist so bridge detected the path but skipped sending. Now supports common text, code, config, and archive formats. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 05b11d9 commit 3975f27

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

bridge.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ const SENDABLE_EXTS = new Set([".png", ".jpg", ".jpeg", ".gif", ".webp", ".pdf",
601601
function extractFilePathsFromText(text, fileList) {
602602
const HOME = process.env.HOME || "/Users/anxianjingya";
603603
const existing = new Set(fileList.map(f => f.filePath));
604-
const extGroup = "png|jpg|jpeg|gif|webp|pdf|docx|xlsx|csv|html|svg";
604+
const extGroup = "png|jpg|jpeg|gif|webp|pdf|docx|xlsx|csv|html|svg|txt|md|json|js|ts|py|sh|yaml|yml|xml|log|zip|tar|gz";
605605

606606
// 1. 绝对路径(/开头)
607607
const absPattern = new RegExp(`(\\/(?:[\\w.\\-]+\\/)*[\\w.\\-\\u4e00-\\u9fff\\u3000-\\u303f\\uff00-\\uffef ]+\\.(?:${extGroup}))`, "gi");
@@ -984,7 +984,7 @@ async function processPrompt(ctx, prompt) {
984984
await progress.start();
985985

986986
// 注入 bridge 行为指令
987-
const bridgeHint = "[系统提示: 你通过 Telegram Bridge 与用户对话。当用户要求截图、生成文件、或发送已有文件时,只需在回复中写出文件的完整绝对路径(如 /Users/anxianjingya/Desktop/file.png),bridge 会自动检测路径并将文件发送给用户。绝对不要自己调用 curl/Telegram Bot API 来发送文件。]\n\n";
987+
const bridgeHint = "[系统提示: 你通过 Telegram Bridge 与用户对话。当用户要求发送文件、截图或查看图片时:1) 用工具找到/生成文件 2) 在回复中包含文件的完整绝对路径(如 /Users/xxx/file.png),bridge 会自动检测路径并发送给用户。用户不需要知道路径,你来找。绝对不要自己调用 curl/Telegram Bot API。]\n\n";
988988
const fullPrompt = await buildPromptWithContext(ctx, bridgeHint + prompt);
989989
const session = getSession(chatId);
990990
// 只复用同后端的 session
@@ -1118,7 +1118,7 @@ async function processPrompt(ctx, prompt) {
11181118

11191119
if (resultSuccess && capturedFiles.length > 0) {
11201120
const IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".gif", ".webp"]);
1121-
const DOC_EXTS = new Set([".pdf", ".docx", ".xlsx", ".csv", ".html"]);
1121+
const DOC_EXTS = new Set([".pdf", ".docx", ".xlsx", ".csv", ".html", ".txt", ".md", ".json", ".js", ".ts", ".py", ".sh", ".yaml", ".yml", ".xml", ".log", ".zip", ".tar", ".gz"]);
11221122
const HOME = process.env.HOME || "";
11231123
const sentPaths = new Set();
11241124
for (const f of capturedFiles) {

0 commit comments

Comments
 (0)