feat: add /info command to show chat ID and subscription status

This commit is contained in:
2026-04-09 12:16:45 +07:00
parent b72e984b0c
commit 500c9c83ee
3 changed files with 25 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ const BOT_COMMANDS = [
{ command: "status", description: "Current system status" },
{ command: "subscribe", description: "Set notification preferences" },
{ command: "history", description: "Recent incidents" },
{ command: "info", description: "Chat ID & subscription info" },
{ command: "uptime", description: "Component health overview" },
];

View File

@@ -132,6 +132,27 @@ function createBot(token) {
});
});
bot.command("info", async (ctx) => {
const { chatId, threadId } = getChatTarget(ctx);
const idLine =
threadId != null ? `<code>${chatId}:${threadId}</code>` : `<code>${chatId}</code>`;
const sub = await getSubscriber(kv, chatId, threadId);
let subLine;
if (!sub) {
subLine = "Not subscribed. Use /start to subscribe.";
} else {
const types = sub.types?.join(", ") || "none";
const components = sub.components?.length ? sub.components.join(", ") : "all";
subLine =
`Types: <code>${types}</code>\n` + `Components: <code>${components}</code>`;
}
await ctx.reply(`<b>Chat Info</b>\n\nChat ID: ${idLine}\n\n${subLine}`, {
parse_mode: "HTML",
});
});
// Info commands: /help, /status, /history, /uptime
registerInfoCommands(bot);
@@ -141,6 +162,7 @@ function createBot(token) {
"/help — Detailed command guide\n" +
"/start — Subscribe to notifications\n" +
"/stop — Unsubscribe\n" +
"/info — Chat ID & subscription info\n" +
"/status — Current system status\n" +
"/subscribe — Notification preferences\n" +
"/history — Recent incidents\n" +

View File

@@ -26,6 +26,8 @@ export function registerInfoCommands(bot) {
`Show current status of all components.\n` +
`Add a component name for a specific check.\n` +
`Example: <code>/status api</code>\n\n` +
`<b>/info</b>\n` +
`Show chat ID and current subscription status.\n\n` +
`<b>/subscribe</b> &lt;type&gt; [component]\n` +
`Set what notifications you receive.\n` +
`Types: <code>incident</code>, <code>component</code>, <code>all</code>\n` +