Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(discord): post milestones without pinging everyone
leepokai054776949a09
diff --git a/discord/README.md b/discord/README.mdindex d962c8fa..5e55bf80 100644--- a/discord/README.md+++ b/discord/README.md@@ -15,7 +15,7 @@ the GitHub roles.5. `/mentions` takes release notes signed with `MENTIONS_SECRET` and turns each `@login` of a linked member intoa Discord mention. Auto Tag (`.github/workflows/auto-tag.yml`) uses it so the #releases post pings the peopleit thanks; the links stay private.-6. Milestones go to #milestones, each once and with `@everyone`, with progress toward the goal and one-click+6. Milestones go to #milestones, each once and without pinging anyone, with progress toward the goal and one-clicklinks to share Codync on X, Threads, Reddit and LinkedIn: every 100th star (`/webhook` takes the repo's`star` events; goal `STAR_GOAL`) and every 1,000th desktop app download (GitHub has no download event, so adaily cron sums the installer downloads of every release: `.dmg`, `.exe`, `.AppImage`, `.deb`, `.rpm`,@@ -35,7 +35,7 @@ issue. The onboarding Server Guide has a "Link your GitHub" to-do that leads to- Discord application **Codync** (Developer Portal): OAuth2 redirect `https://discord.codync.dev/callback`; botnot public. In the server, its role keeps Manage Roles and Create Invite (`guilds.join` needs it), sits aboveContributor and Reporter, and can view and send in #moderator-only and #milestones (read-only for everyone- else), where it may also mention @everyone. On the Support category it may create posts, send in threads and+ else). On the Support category it may create posts, send in threads andmanage threads (the moderator-only **GitHub** and **Shipped** tags, closing posts).- GitHub OAuth app **Codync Discord** (leepokai's developer settings): callback`https://discord.codync.dev/github/callback`, no scopes requested.diff --git a/discord/src/guild.ts b/discord/src/guild.tsindex 9bc3d963..6f25eca3 100644--- a/discord/src/guild.ts+++ b/discord/src/guild.ts@@ -83,14 +83,14 @@ export async function grant(env: Env, discordId: string, earned: Role[], reason:/*** Posts to a channel and says whether it went out. A failure is logged and never fails the caller's flow.- * Only the mention kinds in `pings` notify anyone (none by default).+ * Mentions in it notify no one.*/-export async function send(env: Env, channelId: string, content: string, pings: "everyone"[] = []): Promise<boolean> {+export async function send(env: Env, channelId: string, content: string): Promise<boolean> {const res = await fetch(`${DISCORD}/channels/${channelId}/messages`, {method: "POST",headers: { ...bot(env), "Content-Type": "application/json" },// Flag 4 drops link previews.- body: JSON.stringify({ content, allowed_mentions: { parse: pings }, flags: 4 }),+ body: JSON.stringify({ content, allowed_mentions: { parse: [] }, flags: 4 }),});if (!res.ok) console.error("send failed", { channel: channelId, status: res.status, body: await res.text() });return res.ok;diff --git a/discord/src/milestones.ts b/discord/src/milestones.tsindex 88d126b4..a7682b6a 100644--- a/discord/src/milestones.ts+++ b/discord/src/milestones.ts@@ -1,4 +1,4 @@-// Milestones in #milestones, each posted once with @everyone and the way left to the goal: every 100th GitHub+// Milestones in #milestones, each posted once (no pings) with the way left to the goal: every 100th GitHub// star (from the repo webhook) and every 1,000th download of the desktop app (counted once a day).import { githubAll, send } from "./guild.ts";@@ -32,7 +32,7 @@ export async function celebrate(env: Env, kind: Kind, count: number): Promise<voconst last = Number((await env.LINKS.get(key)) ?? 0);if (milestone <= last) return;// ponytail: KV isn't atomic, so two stars delivered at the same instant on a new milestone could post it twice.- if (await send(env, env.MILESTONES_CHANNEL_ID, milestoneMessage(kind, milestone, Number(KINDS[kind].goal(env)), env.REPO), ["everyone"])) {+ if (await send(env, env.MILESTONES_CHANNEL_ID, milestoneMessage(kind, milestone, Number(KINDS[kind].goal(env)), env.REPO))) {await env.LINKS.put(key, String(milestone));console.log("milestone", { kind, milestone });}@@ -70,5 +70,5 @@ export function milestoneMessage(kind: Kind, count: number, goal: number, repo:const filled = Math.round((count / goal) * BAR);const progress = count < goal ? `\n\`${"█".repeat(filled)}${"░".repeat(BAR - filled)}\` ${n(count)} / ${n(goal)}` : "";const ask = count < goal ? `Help us reach ${n(goal)}: tell people about Codync` : "Keep spreading the word";- return `@everyone ${head}${progress}\n${thanks(repo)}\n\n📣 ${ask} on ${shareLinks(`https://github.com/${repo}`)}, or wherever you hang out.`;+ return `${head}${progress}\n${thanks(repo)}\n\n📣 ${ask} on ${shareLinks(`https://github.com/${repo}`)}, or wherever you hang out.`;}diff --git a/discord/test/claim.test.ts b/discord/test/claim.test.tsindex e1147f46..8562f4aa 100644--- a/discord/test/claim.test.ts+++ b/discord/test/claim.test.ts@@ -174,7 +174,7 @@ assert.deepEqual(await notes("- Fast mode. Thanks @octo (#101).\n@Octo, @other,text: "- Fast mode. Thanks <@42> (#101).\n<@42>, @other, @nobody, [email protected], `@octo_x`",users: ["42"],});-// Milestones: each 100th star and 1,000th download posts once in #milestones and pings everyone, with progress+// Milestones: each 100th star and 1,000th download posts once in #milestones without pinging anyone, with progress// toward the goal until it's reached.const posts: string[] = [];let up = true;@@ -187,7 +187,7 @@ globalThis.fetch = (async (input: string, init?: RequestInit) => {assert.equal(url, "https://discord.com/api/v10/channels/milestones/messages");if (!up) return new Response("down", { status: 503 });const body = JSON.parse(String(init?.body));- assert.deepEqual(body.allowed_mentions, { parse: ["everyone"] });+ assert.deepEqual(body.allowed_mentions, { parse: [] });posts.push(body.content);return Response.json({});}) as typeof fetch;@@ -202,9 +202,9 @@ up = true;for (const count of [402, 401, 400, 450, 1000, 1000, 1104]) assert.equal(await star(count), 204);const thanks = "Thanks to everyone who starred [leepokai/Codync](https://github.com/leepokai/Codync) 💛\n\n📣 ";assert.equal(posts.length, 3);-assert.ok(posts[0].startsWith(`@everyone ⭐ **Codync just hit 400 stars on GitHub!**\n\`████████░░░░░░░░░░░░\` 400 / 1,000\n${thanks}Help us reach 1,000: tell people about Codync on [X](https://x.com/intent/post?text=Codync%3A%20`));-assert.ok(posts[1].startsWith(`@everyone 🎉 **Codync hit 1,000 stars on GitHub, goal reached!**\n${thanks}Keep spreading the word on [X](`));-assert.ok(posts[2].startsWith(`@everyone ⭐ **Codync just hit 1,100 stars on GitHub!**\n${thanks}Keep spreading the word on [X](`));+assert.ok(posts[0].startsWith(`⭐ **Codync just hit 400 stars on GitHub!**\n\`████████░░░░░░░░░░░░\` 400 / 1,000\n${thanks}Help us reach 1,000: tell people about Codync on [X](https://x.com/intent/post?text=Codync%3A%20`));+assert.ok(posts[1].startsWith(`🎉 **Codync hit 1,000 stars on GitHub, goal reached!**\n${thanks}Keep spreading the word on [X](`));+assert.ok(posts[2].startsWith(`⭐ **Codync just hit 1,100 stars on GitHub!**\n${thanks}Keep spreading the word on [X](`));assert.match(posts[0], /\[Threads\]\(.+\) · \[Reddit\]\(.+url=https%3A%2F%2Fgithub.com%2Fleepokai%2FCodync.+\) · \[LinkedIn\]\(.+\), or wherever you hang out\.$/);assert.equal(links.get("stars:milestone"), "1100");@@ -224,6 +224,6 @@ releases[1].push(release(asset("codync-linux-x86_64.deb", 1)));await cron();await cron();assert.equal(posts.length, 1);-assert.ok(posts[0].startsWith("@everyone 📦 **Codync just hit 1,000 downloads!**\n`██░░░░░░░░░░░░░░░░░░` 1,000 / 10,000\nThanks to everyone who gave it a try 💛\n\n📣 Help us reach 10,000:"));+assert.ok(posts[0].startsWith("📦 **Codync just hit 1,000 downloads!**\n`██░░░░░░░░░░░░░░░░░░` 1,000 / 10,000\nThanks to everyone who gave it a try 💛\n\n📣 Help us reach 10,000:"));assert.equal(links.get("downloads:milestone"), "1000");console.log("claim tests ok");