snapshot before merge

This commit is contained in:
zqlit committed 2026-06-01 17:57:22 +08:00
1 parent 06a5f3da4d
commit 671871e0b2
145 files changed
+9786 -59

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
const fs = require("fs");
const path = "E:/GitHub/blog/bot/index.js";
let c = fs.readFileSync(path, "utf8");
function findBlock(name) {
var idx = c.indexOf("CMD_HANDLERS." + name);
if (idx === -1) return null;
var depth = 0;
var i = idx;
for (; i < c.length; i++) {
if (c[i] === "{") depth++;
else if (c[i] === "}") {
depth--;
if (depth === 0) break;
}
}
return { start: idx, end: i + 2 };
}
// Fix 1: link_del (was missed earlier)
var b = findBlock("link_del");
if (!b) { console.log("ERR: link_del not found"); process.exit(1); }
var nb =
"CMD_HANDLERS.link_del = async function (chatId, url) {\n" +
" if (!url) return sendMessage(chatId, \"Usage: /link_del <url>\\nUse /links to find the URL.\");\n" +
" try {\n" +
" const res = await fetch(\"http://127.0.0.1:\" + WRITE_PORT + \"/api/rss/links?url=\" + encodeURIComponent(url), {\n" +
" method: \"DELETE\",\n" +
" });\n" +
" if (!res.ok) throw new Error((await res.json()).error || \"Delete failed\");\n" +
" return sendMessage(chatId, \"\u2702 Link deleted: \" + url);\n" +
" } catch (e) {\n" +
" return sendMessage(chatId, \"\u274c \" + e.message);\n" +
" }\n" +
"};\n";
c = c.substring(0, b.start) + nb + c.substring(b.end);
console.log("1/1: link_del fixed");
fs.writeFileSync(path, c, "utf8");
console.log("Done!");