Update handlers.ts
This commit is contained in:
1 parent
97217d0cc0
commit
fdfa6007d4
1 file changed
+44
-9
@@ -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, "✅ <b>已启动</b>\n\n📱 手机: http://" + ip + ":8016/\n💻 电脑: http://localhost:8016/");
|
||||
await sendMain(chatId, [
|
||||
`👋 <b>欢迎使用写作后台!</b>`,
|
||||
``,
|
||||
`📝 <b>功能菜单:</b>`,
|
||||
`├─ /new - 新建文章`,
|
||||
`├─ /edit - 编辑文章`,
|
||||
`├─ /list - 文章列表`,
|
||||
`├─ /deploy - 部署博客`,
|
||||
`└─ /status - 服务器状态`,
|
||||
``,
|
||||
`🌐 <b>访问地址:</b>`,
|
||||
`├─ 📊 后台管理:https://post.usj.cc`,
|
||||
`└─ 🌍 博客首页:https://usj.cc`,
|
||||
``,
|
||||
`💡 <b>提示:</b>`,
|
||||
`• 使用 /new 开始写作`,
|
||||
`• 发送文字直接创建草稿`,
|
||||
`• 发送语音自动转文字`,
|
||||
``,
|
||||
`🎯 <b>开始写作吧!</b>`,
|
||||
].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 = ["<b>Hugo:</b> " + 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 = [
|
||||
`📊 <b>服务器状态</b>`,
|
||||
``,
|
||||
`🖥️ <b>Hugo 服务:</b>`,
|
||||
`├─ 状态:${statusEmoji} ${statusText}`,
|
||||
`└─ 地址:https://post.usj.cc`,
|
||||
``,
|
||||
s.running ? `🟢 <b>服务正常运行中</b>` : `🔴 <b>服务未运行</b>`,
|
||||
].join("\n");
|
||||
|
||||
await sendMain(chatId, msg);
|
||||
};
|
||||
|
||||
handlers.ip = async (chatId) => { await sendMain(chatId, "Phone: http://" + getLanIP() + ":8016"); };
|
||||
handlers.ip = async (chatId) => {
|
||||
await sendMain(chatId, [
|
||||
`🌐 <b>访问地址</b>`,
|
||||
``,
|
||||
`├─ 📊 后台管理:https://post.usj.cc`,
|
||||
`└─ 🌍 博客首页:https://usj.cc`,
|
||||
].join("\n"));
|
||||
};
|
||||
|
||||
handlers.shutdown = async (chatId) => {
|
||||
await tg("sendMessage", {
|
||||
|
||||
Reference in new issue
Block a user