From fdfa6007d43239ed80facabb9979a445d4e5f287 Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:40:38 +0800 Subject: [PATCH] Update handlers.ts --- write-server/src/lib/bot/handlers.ts | 53 +++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/write-server/src/lib/bot/handlers.ts b/write-server/src/lib/bot/handlers.ts index 2d09785a..08f8c33e 100644 --- a/write-server/src/lib/bot/handlers.ts +++ b/write-server/src/lib/bot/handlers.ts @@ -94,13 +94,31 @@ async function sendWrite(chatId: number, text: string) { // ---- System ---- handlers.start = async (chatId) => { - const ok = await hugo.ensureRunning(); - const ip = getLanIP(); - await sendMain(chatId, "✅ 已启动\n\n📱 手机: http://" + ip + ":8016/\n💻 电脑: http://localhost:8016/"); + await sendMain(chatId, [ + `👋 欢迎使用写作后台!`, + ``, + `📝 功能菜单:`, + `├─ /new - 新建文章`, + `├─ /edit - 编辑文章`, + `├─ /list - 文章列表`, + `├─ /deploy - 部署博客`, + `└─ /status - 服务器状态`, + ``, + `🌐 访问地址:`, + `├─ 📊 后台管理:https://post.usj.cc`, + `└─ 🌍 博客首页:https://usj.cc`, + ``, + `💡 提示:`, + `• 使用 /new 开始写作`, + `• 发送文字直接创建草稿`, + `• 发送语音自动转文字`, + ``, + `🎯 开始写作吧!`, + ].join("\n")); await tg("sendMessage", { chat_id: chatId, text: "点下方按钮打开编辑器:", - reply_markup: { inline_keyboard: [[{ text: "🌐 打开编辑器", web_app: { url: "http://" + ip + ":8016/" } }]] }, + reply_markup: { inline_keyboard: [[{ text: "🌐 打开编辑器", web_app: { url: "https://post.usj.cc" } }]] }, }); }; @@ -108,13 +126,30 @@ handlers.stop = async (chatId) => { hugo.stop(); await sendMain(chatId, "⚡ Hug handlers.status = async (chatId) => { const s = hugo.status(); - const status = s.running ? "✅ 运行中" : s.starting ? "⏳ 启动中..." : "⏸ 已停止"; - const lines = ["Hugo: " + status]; - if (s.running) { const ip = getLanIP(); lines.push("📱 http://" + ip + ":8016", "💻 http://localhost:8016"); } - await sendMain(chatId, lines.join("\n")); + const statusEmoji = s.running ? "✅" : s.starting ? "⏳" : "⏸"; + const statusText = s.running ? "运行中" : s.starting ? "启动中..." : "已停止"; + + const msg = [ + `📊 服务器状态`, + ``, + `🖥️ Hugo 服务:`, + `├─ 状态:${statusEmoji} ${statusText}`, + `└─ 地址:https://post.usj.cc`, + ``, + s.running ? `🟢 服务正常运行中` : `🔴 服务未运行`, + ].join("\n"); + + await sendMain(chatId, msg); }; -handlers.ip = async (chatId) => { await sendMain(chatId, "Phone: http://" + getLanIP() + ":8016"); }; +handlers.ip = async (chatId) => { + await sendMain(chatId, [ + `🌐 访问地址`, + ``, + `├─ 📊 后台管理:https://post.usj.cc`, + `└─ 🌍 博客首页:https://usj.cc`, + ].join("\n")); +}; handlers.shutdown = async (chatId) => { await tg("sendMessage", {