feat: add in-chat logs for mod-actions and report#66
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughSuppresses success confirmations across moderation commands (ban/del/kick/mute), making handlers reply only on error; enhances report to give conditional formatted feedback; adds TgLogger.chat-side moderation logging for moderator actions; extends fmtUser to optionally hide user IDs. Changes
Sequence Diagram(s)mermaid Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/commands/ban.ts (1)
30-34: Consider centralizing the transient error-reply flow.The same
reply → wait(5000) → deletesequence is now repeated inban,tban, andunbanhere, and the same pattern shows up in the other moderation commands in this PR. A tiny helper would keep timeout/delete behavior consistent and give you one place to harden if reply deletion starts failing.Also applies to: 70-74, 109-113
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/ban.ts` around lines 30 - 34, Extract the repeated "reply → wait(5000) → delete" flow into a single helper (e.g., sendTransientReply or replyThenDelete) and replace the blocks in ban, tban, and unban that check res.isErr() (and any similar moderation command error branches) to call that helper instead of duplicating the logic; the helper should accept the context/message content and optional timeout (default 5000ms), await the reply, await the timeout, attempt to delete the message and catch/log delete errors so failures are handled centrally and consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/report.ts`:
- Around line 19-33: The public reply in the context.reply success branch
exposes the reporter by using fmtUser(context.from); update the behavior so the
acknowledgment is anonymous: remove fmtUser(context.from) from the success
message and replace it with a generic confirmation (e.g., "Thanks — moderators
have been notified.") or send the confirmation privately via a direct message to
the reporter (use context.from to DM, but do not mention them in the group
reply). Change the message construction in the code block that uses reportSent
and fmt to eliminate any reference to context.from or fmtUser while keeping the
same reply metadata (reply_parameters/message_id) logic.
In `@src/modules/tg-logger/index.ts`:
- Around line 513-520: The message construction for MOD_ACTION_TITLE(p)
currently includes moderator-supplied p.reason (see msg creation and fmtUser
usage), which must not be echoed to public chat; remove inclusion of "reason"
from the public fmt output and only include action, target, moderator and
optional duration, and if you need a public-facing rationale use a separate
curated field (e.g., p.publicReason) instead; keep the original p.reason in
internal/admin logs but ensure the code paths that build the public msg (the fmt
call that produces msg and the same pattern at the related block around 524-528)
do not interpolate p.reason into messages sent to the group.
---
Nitpick comments:
In `@src/commands/ban.ts`:
- Around line 30-34: Extract the repeated "reply → wait(5000) → delete" flow
into a single helper (e.g., sendTransientReply or replyThenDelete) and replace
the blocks in ban, tban, and unban that check res.isErr() (and any similar
moderation command error branches) to call that helper instead of duplicating
the logic; the helper should accept the context/message content and optional
timeout (default 5000ms), await the reply, await the timeout, attempt to delete
the message and catch/log delete errors so failures are handled centrally and
consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5a10ce5f-978d-47b5-97df-738bcb658194
📒 Files selected for processing (8)
src/commands/ban.tssrc/commands/del.tssrc/commands/kick.tssrc/commands/mute.tssrc/commands/report.tssrc/modules/moderation/index.tssrc/modules/tg-logger/index.tssrc/utils/format.ts
💤 Files with no reviewable changes (1)
- src/modules/moderation/index.ts
No description provided.