diff --git a/CLAUDE.md b/CLAUDE.md index 14cfebb..add01e7 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -59,5 +59,5 @@ Bot stores `message_thread_id` from the topic where `/start` was sent. Notificat ## CF Bindings (wrangler.jsonc) -- `SUBSCRIBERS` — KV namespace +- `CLAUDE_STATUS` — KV namespace - `STATUS_QUEUE` — Queue producer/consumer (`claude-status`, batch size 30, max retries 3) diff --git a/README.md b/README.md index 9b15d40..22a914b 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ npx wrangler login ### 3. Create KV namespace and Queue ```bash -npx wrangler kv namespace create SUBSCRIBERS +npx wrangler kv namespace create claude-status npx wrangler queues create claude-status ``` @@ -58,7 +58,7 @@ Copy the KV namespace ID from the output and update `wrangler.jsonc`: ```jsonc "kv_namespaces": [ - { "binding": "SUBSCRIBERS", "id": "YOUR_KV_NAMESPACE_ID" } + { "binding": "CLAUDE_STATUS", "id": "YOUR_KV_NAMESPACE_ID" } ] ``` diff --git a/src/bot-commands.js b/src/bot-commands.js index 740950c..00783a8 100644 --- a/src/bot-commands.js +++ b/src/bot-commands.js @@ -18,7 +18,7 @@ import { function getChatTarget(ctx) { return { chatId: ctx.chat.id, - threadId: ctx.message?.message_thread_id || null, + threadId: ctx.message?.message_thread_id ?? null, }; } @@ -27,7 +27,7 @@ function getChatTarget(ctx) { */ export async function handleTelegramWebhook(c) { const bot = new Bot(c.env.BOT_TOKEN); - const kv = c.env.SUBSCRIBERS; + const kv = c.env.CLAUDE_STATUS; bot.command("start", async (ctx) => { const { chatId, threadId } = getChatTarget(ctx); diff --git a/src/queue-consumer.js b/src/queue-consumer.js index 1baabec..3f6c319 100644 --- a/src/queue-consumer.js +++ b/src/queue-consumer.js @@ -36,7 +36,7 @@ export async function handleQueue(batch, env) { msg.ack(); } else if (res.status === 403 || res.status === 400) { // Bot blocked or chat not found — auto-remove subscriber - await removeSubscriber(env.SUBSCRIBERS, chatId, threadId); + await removeSubscriber(env.CLAUDE_STATUS, chatId, threadId); msg.ack(); } else if (res.status === 429) { // Rate limited — let queue retry later diff --git a/src/statuspage-webhook.js b/src/statuspage-webhook.js index 86a435b..b8292c4 100644 --- a/src/statuspage-webhook.js +++ b/src/statuspage-webhook.js @@ -69,7 +69,7 @@ export async function handleStatuspageWebhook(c) { } // Get filtered subscribers - const subscribers = await getSubscribersByType(c.env.SUBSCRIBERS, category); + const subscribers = await getSubscribersByType(c.env.CLAUDE_STATUS, category); // Enqueue messages for fan-out via CF Queues (batch for performance) const messages = subscribers.map(({ chatId, threadId }) => ({ diff --git a/wrangler.jsonc b/wrangler.jsonc index 65f3fbe..6308907 100644 --- a/wrangler.jsonc +++ b/wrangler.jsonc @@ -3,7 +3,7 @@ "main": "src/index.js", "compatibility_date": "2024-12-01", "kv_namespaces": [ - { "binding": "SUBSCRIBERS", "id": "" } + { "binding": "CLAUDE_STATUS", "id": "" } ], "queues": { "producers": [