mirror of
https://github.com/tiennm99/claude-status-webhook.git
synced 2026-04-17 09:20:28 +00:00
feat: add /info command to show chat ID and subscription status
This commit is contained in:
@@ -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" },
|
||||
];
|
||||
|
||||
|
||||
@@ -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" +
|
||||
|
||||
@@ -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> <type> [component]\n` +
|
||||
`Set what notifications you receive.\n` +
|
||||
`Types: <code>incident</code>, <code>component</code>, <code>all</code>\n` +
|
||||
|
||||
Reference in New Issue
Block a user