feat: search command responds to repliedTo or invoker msg#71
feat: search command responds to repliedTo or invoker msg#71lorenzocorallo merged 2 commits intomainfrom
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe search command handler signature now accepts a Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
📝 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/commands/search.ts (1)
24-24: Deduplicate reply target resolution to reduce drift risk.Line 24 and Line 53 repeat the same fallback expression. Consider computing it once and reusing it in both replies.
♻️ Proposed refactor
handler: async ({ context, args, repliedTo }) => { + const replyToMessageId = repliedTo?.message_id ?? context.msgId const res = await api.tg.groups.search.query({ query: args.query, limit: LIMIT }) if (res.count === 0) { await context.reply( fmt(({ n, b, i }) => [b`🔎 Group Search`, n`${i`Query:`} ${b`${args.query}`}`, b`❌ No results`], { sep: "\n", }), - { reply_parameters: { message_id: repliedTo ? repliedTo.message_id : context.msgId } } + { reply_parameters: { message_id: replyToMessageId } } ) return } @@ await context.reply(reply, { link_preview_options: { is_disabled: true }, reply_markup: inlineKeyboard, - reply_parameters: { message_id: repliedTo ? repliedTo.message_id : context.msgId }, + reply_parameters: { message_id: replyToMessageId }, }) },Also applies to: 53-53
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/search.ts` at line 24, The reply target is computed twice using the fallback expression repliedTo ? repliedTo.message_id : context.msgId; compute it once (e.g., const targetMessageId = repliedTo?.message_id ?? context.msgId) near the start of the handler and reuse targetMessageId in both reply payloads instead of repeating the expression to avoid drift; update the two locations that set reply_parameters.message_id to use targetMessageId (referencing repliedTo and context.msgId for the original values).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/commands/search.ts`:
- Line 24: The reply target is computed twice using the fallback expression
repliedTo ? repliedTo.message_id : context.msgId; compute it once (e.g., const
targetMessageId = repliedTo?.message_id ?? context.msgId) near the start of the
handler and reuse targetMessageId in both reply payloads instead of repeating
the expression to avoid drift; update the two locations that set
reply_parameters.message_id to use targetMessageId (referencing repliedTo and
context.msgId for the original values).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8c7eeb81-fe5b-4832-baf7-f1aeeb4592de
📒 Files selected for processing (1)
src/commands/search.ts
closes #57