Repository navigation
Discord chat: a starboard for messages that collect enough ⭐ - #448
TripleU613 wants to merge 2 commits into
Conversation
discord_chat_welcome_message is sent once, as a direct message, to each
member whose linked account lets them in, with {username} filled in. Only
people who joined the server in the last 7 days are welcomed, at most 10
per run so a launch rush isn't throttled as spam. A member is marked
welcomed before the message goes out, so closed direct messages aren't
retried every minute. Blank, the default, sends nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BUGDaR7qv2d8CuVp7UGSTs
Every 2 minutes the forum reads the last 50 messages of each channel listed in discord_chat_starboard_channels and reposts, once, any that reached discord_chat_starboard_threshold ⭐ (3 by default) into discord_chat_starboard_channel_id: author, text, first image and a link back, pinging nobody. Only listed channels are read, so a starred message in a private channel the bot can see never reaches members. Bot messages and messages older than 7 days are skipped. Off until a starboard channel is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BUGDaR7qv2d8CuVp7UGSTs
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cccdd67aab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private | ||
|
|
||
| def sources | ||
| SiteSetting.discord_chat_starboard_channels.to_s.split("|").map(&:strip).reject(&:blank?) |
There was a problem hiding this comment.
Prevent private channels from entering the source list
The source list accepts raw channel IDs without checking their Discord visibility, so a mistaken ID—or a channel that becomes private after configuration—causes its starred message text and image to be copied into a more widely visible starboard. The allowlist therefore does not guarantee the class comment's claim that private-channel messages never reach members; validate that each source is at least as visible as the target before reading or reposting it.
AGENTS.md reference: AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
| PluginStore.set(STORE, key(message["id"]), true) | ||
| @api.bot(:post, "/channels/#{target}/messages", repost(message, channel_id)) |
There was a problem hiding this comment.
Record completion only after Discord accepts the repost
If the following POST is rejected, particularly with a 429 or another transient Discord error, this key remains stored while the scheduled job rescues the exception. Every later run then treats the message as completed and skips it permanently, so store the key only after a successful POST or remove it on a known failure.
Useful? React with 👍 / 👎.
|
|
||
| sources.each do |channel_id| | ||
| next if channel_id == target | ||
| messages = @api.bot(:get, "/channels/#{channel_id}/messages", query: { limit: LOOKBACK }) |
There was a problem hiding this comment.
Paginate past the newest 50 messages
In a channel where a message reaches the threshold only after 50 newer messages exist—or where more than 50 messages arrive between two-minute runs—it is never examined and therefore never reaches the starboard despite remaining inside the advertised seven-day window. Discord returns this endpoint newest-first and provides before/after cursors, so retain a per-channel cursor and paginate the interval rather than repeatedly requesting only the newest 50 (Discord API documentation).
Useful? React with 👍 / 👎.
Every 2 min, reads the last 50 messages of the allowlisted channels (
discord_chat_starboard_channels) and reposts once any with ≥ threshold ⭐ todiscord_chat_starboard_channel_id, no pings. Skips bots and >7-day-old messages. Off until a channel is set. Specs: once only, thresholds/bots/age, unlisted channel never read, off.Stacked on discord-chat/welcome-dm; retargets to main once that merges.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BUGDaR7qv2d8CuVp7UGSTs