feat: add /help, /history, /uptime commands and enhance /status

- /help: detailed guide with examples for all commands
- /status: overall indicator, emoji markers, updated time, status page link
- /history [count]: recent incidents with impact, dates, links (max 10)
- /uptime: component health with last change time
- Split info commands into bot-info-commands.js for modularity
- Register all 7 commands in bot-setup.js
This commit is contained in:
2026-04-08 23:41:53 +07:00
parent 37c2a01677
commit 30ffaae612
6 changed files with 209 additions and 35 deletions

View File

@@ -6,11 +6,7 @@ import {
getSubscribers,
buildSubscriberKey,
} from "./kv-store.js";
import {
fetchAllComponents,
fetchComponentByName,
formatComponentLine,
} from "./status-fetcher.js";
import { registerInfoCommands } from "./bot-info-commands.js";
/**
* Extract chatId and threadId from grammY context
@@ -48,26 +44,6 @@ export async function handleTelegramWebhook(c) {
});
});
bot.command("status", async (ctx) => {
const args = ctx.match?.trim();
try {
if (args) {
const component = await fetchComponentByName(args);
if (!component) {
await ctx.reply(`Component "<code>${args}</code>" not found.`, { parse_mode: "HTML" });
return;
}
await ctx.reply(formatComponentLine(component), { parse_mode: "HTML" });
} else {
const components = await fetchAllComponents();
const lines = components.map(formatComponentLine);
await ctx.reply(`<b>Claude Status</b>\n\n${lines.join("\n")}`, { parse_mode: "HTML" });
}
} catch {
await ctx.reply("Unable to fetch status. Please try again later.");
}
});
bot.command("subscribe", async (ctx) => {
const { chatId, threadId } = getChatTarget(ctx);
const arg = ctx.match?.trim().toLowerCase();
@@ -97,14 +73,19 @@ export async function handleTelegramWebhook(c) {
});
});
// Info commands: /help, /status, /history, /uptime
registerInfoCommands(bot);
bot.on("message", async (ctx) => {
await ctx.reply(
"<b>Claude Status Bot</b>\n\n" +
"/help — Detailed command guide\n" +
"/start — Subscribe to notifications\n" +
"/stop — Unsubscribe\n" +
"/status — Check current status\n" +
"/status &lt;component&gt; — Check specific component\n" +
"/subscribe &lt;type&gt; — Set notification preference",
"/status — Current system status\n" +
"/subscribe — Notification preferences\n" +
"/history — Recent incidents\n" +
"/uptime — Component health overview",
{ parse_mode: "HTML" }
);
});