1578
This commit is contained in:
1 parent
fdfa6007d4
commit
5b05050ebe
2 files changed
+49
-2
No files matched your search
@@ -561,6 +561,28 @@ handlers.link_edit = async (chatId, arg) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 处理友链编辑的回复
|
||||||
|
handlers.handleLinkEditReply = async (chatId, newName) => {
|
||||||
|
const s = getSession(chatId);
|
||||||
|
const oldUrl = s.originalSlug;
|
||||||
|
if (!oldUrl) { await sendMain(chatId, "⚠️ 会话已过期,请重新执行 /link_edit"); return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 如果用户输入了新名称,更新友链
|
||||||
|
if (newName && newName.trim()) {
|
||||||
|
await updateLink(oldUrl, { name: newName.trim() });
|
||||||
|
await sendMain(chatId, "✅ 友链已更新:" + newName.trim());
|
||||||
|
} else {
|
||||||
|
await sendMain(chatId, "ℹ️ 未做修改");
|
||||||
|
}
|
||||||
|
// 清除保存的 URL
|
||||||
|
s.originalSlug = undefined;
|
||||||
|
invalidateByPrefix("links");
|
||||||
|
} catch (e) {
|
||||||
|
await sendMain(chatId, "⚠️ 更新失败,请稍后再试");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
handlers.link_del = async (chatId, url) => {
|
handlers.link_del = async (chatId, url) => {
|
||||||
if (!url) { await sendMain(chatId, "格式:/link_del url"); return; }
|
if (!url) { await sendMain(chatId, "格式:/link_del url"); return; }
|
||||||
try { await deleteLink(url); invalidateByPrefix("links"); await sendMain(chatId, "✅ 已删除:" + url); }
|
try { await deleteLink(url); invalidateByPrefix("links"); await sendMain(chatId, "✅ 已删除:" + url); }
|
||||||
@@ -626,6 +648,31 @@ handlers.feed_edit = async (chatId, arg) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 处理订阅编辑的回复
|
||||||
|
handlers.handleFeedEditReply = async (chatId, newText) => {
|
||||||
|
const s = getSession(chatId);
|
||||||
|
const oldUrl = s.originalSlug;
|
||||||
|
if (!oldUrl) { await sendMain(chatId, "⚠️ 会话已过期,请重新执行 /feed_edit"); return; }
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (newText && newText.trim()) {
|
||||||
|
const parts = newText.trim().split(/\s+/);
|
||||||
|
const newUrl = parts[0] || oldUrl;
|
||||||
|
const feedTitle = parts.slice(1).join(" ") || "";
|
||||||
|
|
||||||
|
await updateFeed(oldUrl, newUrl, feedTitle);
|
||||||
|
await sendMain(chatId, "✅ 订阅源已更新:" + (feedTitle || newUrl));
|
||||||
|
} else {
|
||||||
|
await sendMain(chatId, "ℹ️ 未做修改");
|
||||||
|
}
|
||||||
|
// 清除保存的 URL
|
||||||
|
s.originalSlug = undefined;
|
||||||
|
invalidateByPrefix("feeds");
|
||||||
|
} catch (e) {
|
||||||
|
await sendMain(chatId, "⚠️ 更新失败,请稍后再试");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
handlers.feed_del = async (chatId, url) => {
|
handlers.feed_del = async (chatId, url) => {
|
||||||
if (!url) { await sendMain(chatId, "格式:/feed_del url"); return; }
|
if (!url) { await sendMain(chatId, "格式:/feed_del url"); return; }
|
||||||
try { await deleteFeed(url); invalidateByPrefix("feeds"); await sendMain(chatId, "✅ 已删除:" + url); }
|
try { await deleteFeed(url); invalidateByPrefix("feeds"); await sendMain(chatId, "✅ 已删除:" + url); }
|
||||||
|
|||||||
@@ -119,9 +119,9 @@ export async function startPolling(): Promise<void> {
|
|||||||
if (original.includes("请输入分类")) { await handleCommand(chatId, "categories", fullText); continue; }
|
if (original.includes("请输入分类")) { await handleCommand(chatId, "categories", fullText); continue; }
|
||||||
if (original.includes("请输入标签")) { await handleCommand(chatId, "tags", fullText); continue; }
|
if (original.includes("请输入标签")) { await handleCommand(chatId, "tags", fullText); continue; }
|
||||||
if (original.includes("请输入友链信息")) { await handleCommand(chatId, "link_add", fullText); continue; }
|
if (original.includes("请输入友链信息")) { await handleCommand(chatId, "link_add", fullText); continue; }
|
||||||
if (original.includes("请输入新名称")) { await handleCommand(chatId, "link_edit", fullText); continue; }
|
if (original.includes("请输入新名称")) { await handlers.handleLinkEditReply(chatId, fullText); continue; }
|
||||||
if (original.includes("请输入订阅源 URL")) { await handleCommand(chatId, "feed_add", fullText); continue; }
|
if (original.includes("请输入订阅源 URL")) { await handleCommand(chatId, "feed_add", fullText); continue; }
|
||||||
if (original.includes("请输入新的订阅信息")) { await handleCommand(chatId, "feed_edit", fullText); continue; }
|
if (original.includes("请输入新的订阅信息")) { await handlers.handleFeedEditReply(chatId, fullText); continue; }
|
||||||
}
|
}
|
||||||
|
|
||||||
const parts = fullText.split("@")[0].split(/\s+/);
|
const parts = fullText.split("@")[0].split(/\s+/);
|
||||||
|
|||||||
Reference in new issue
Block a user