feat: add honeypot anti-spam channel - #31
Conversation
Adds an optional honeypot channel (HONEYPOT_CHANNEL_ID) that auto-bans anyone who posts in it, falling back to kick if the ban fails. The bot posts an idempotent warning message on startup (skipped if one already exists) and sweeps messages older than 16h hourly, preserving the warning message. Closes #24
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a Discord honeypot feature that watches a configured hidden channel, removes trigger messages, bans or kicks authors, periodically cleans up older messages, and wires the handler into startup. It also documents the environment variable and adds tests for setup behavior. ChangesHoneypot Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant HoneypotHandler
participant Channel
participant Author
Client->>HoneypotHandler: ClientReady
HoneypotHandler->>Channel: ensureHoneypotMessage()
HoneypotHandler->>Channel: cleanupOldMessages() (initial + hourly)
Author->>Channel: post message
Channel->>HoneypotHandler: MessageCreate event
HoneypotHandler->>Channel: delete message
HoneypotHandler->>Author: ban (fallback: kick)
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: Stream initialization permanently failed: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Comment |
This comment was marked as resolved.
This comment was marked as resolved.
Signed-off-by: Niv <148060940+Nivmizz7@users.noreply.github.com>
…fetches Addresses review findings on #31: - Timer leak: client.on(Events.ClientReady) re-fires on reconnect, each time registering a new setInterval. Switch to client.once, matching bot.js's existing pattern. (Kilo Code, CodeAnt) - Single-page fetch: ensureHoneypotMessage and cleanupOldMessages only inspected the first 50/100 messages, so an existing marker beyond that window caused a duplicate warning and old messages were never swept. Both now paginate via a `before` cursor, bounded by MAX_FETCH_PAGES (1000 messages) to prevent unbounded API calls. (CodeRabbit, CodeAnt, Kilo Code) Test now also asserts ClientReady is registered via .once, not .on.
|
Hey @Nivmizz7 — both PRs are ready to merge and have been re-approved by CodeRabbit after the review fixes:
The only failing check is When you merge, please verify the honeypot works end-to-end on the server:
|
|
LGTM |
User description
Summary
HONEYPOT_CHANNEL_ID) that auto-bans anyone who posts in it, falling back to kick if the ban fails (permissions/hierarchy).HONEYPOT_CHANNEL_IDis optional — when unset the feature is a no-op, so existing deployments and the test suite are unaffected.src/handlers/honeypotHandler.js, following the existingsetupXxx(client)handler pattern and wired intobot.js.Closes #24.
Design notes
setInterval(hourly) over cron/sweepers: the bot process is already the scheduler, and discord.js sweepers only clear the local cache, not Discord messages.Test plan
npm test— 6/6 pass (4 existing env tests + 2 new honeypot tests: no-op when unset, registers listener when enabled)node --checksyntax sweep passes on all JS filesrequiredEnvVars— feature is opt-inCodeAnt-AI Description
Add an optional honeypot channel that bans spam accounts and keeps the channel clean
What Changed
Impact
✅ Fewer spam posts in hidden channels✅ Faster removal of unwanted messages✅ Clearer setup for optional anti-spam protection💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.