Conversation
Release: MCPツールの追加&GPTバージョンアップ
chore: bump dependencies
📝 Walkthroughウォークスルーメッセージ内の trap.jp 参照を検出して元メッセージを取得・検証し、マークダウンの引用ブロックとして組み立てるフォーマッターを追加しました。チャンネルパスとユーザー情報の取得に1時間TTLのキャッシュ層を導入し、ハンドラーでフォーマット結果を使用します。 変更内容
シーケンス図sequenceDiagram
participant Handler as Handler
participant Formatter as Formatter
participant BotCache as Bot API (Cache)
participant TrapAPI as Trap API
Handler->>Formatter: FormatQuotedMessage(userID, content)
Formatter->>Formatter: 抽出: trap.jp URL を正規表現で検出
loop 各 messageID
Formatter->>BotCache: GetMessage(messageID)
BotCache->>TrapAPI: Fetch message details
TrapAPI-->>BotCache: Message data
BotCache-->>Formatter: Message content
Formatter->>BotCache: GetChannelPath(channelID)
BotCache-->>Formatter: Channel path
Formatter->>BotCache: GetUser(authorID)
BotCache-->>Formatter: User details
Formatter->>Formatter: isChannelAllowingQuotes / isUserAllowingQuotes
Formatter->>Formatter: トランケートとMarkdown引用生成
end
Formatter->>Formatter: 元コンテンツからURL除去し引用を付加
Formatter-->>Handler: フォーマット済みコンテンツ
推定レビュー難度🎯 3 (Moderate) | ⏱️ ~22 分 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/bot/channel.go`:
- Around line 13-17: The linter fails due to a missing blank line between the
if-block and the following return in the code that calls
bot.API().ChannelAPI.GetChannelPath(ctx, channelID).Execute(); update the
function containing that snippet to insert a single empty line between the
closing brace of the "if err != nil { return "", err }" block and "return
path.Path, nil" so it conforms to the nlreturn rule (locate the call to
GetChannelPath and the variables path and err to find the exact spot).
In `@internal/bot/user.go`:
- Around line 14-18: The linter fails due to missing blank line before the final
return; update the function that calls bot.API().UserAPI.GetUser (the block that
checks err) to add a single empty line between the closing `if err != nil {
return nil, err }` block and the subsequent `return user, nil` so there is a
blank line separating the error-handling if and the final return.
In `@internal/pkg/formatter/quotes.go`:
- Around line 100-102: for ループの終了直後に return formattedContent.String(), nil
が続いており nlreturn によって CI が落ちているので、quotes.go
内の該当ブロック(formattedContent.WriteString("\n\n" + quote) を含むループ)と return
formattedContent.String(), nil の間に空行を挿入して改行ルールに従わせてください。対象の識別子:
formattedContent.WriteString と return formattedContent.String(), nil
を見つけて、その間に1行の空行を追加してください。
- Around line 32-46: isUserAllowingQuotes currently fetches the wrong user and
compares IDs in the wrong direction; treat the first arg as the requester ID and
the second as the quoted-message author ID, call bot.GetUser(messageUserID) (not
bot.GetUser(userID)), then allow when the quoted-message author is a bot
(messageUser.Bot) or when the quoted-message author ID equals the requester ID;
update the comparisons and the bot.GetUser call inside isUserAllowingQuotes
accordingly (use messageUserID for lookup and compare messageUser.ID to userID).
- Around line 80-82: The current truncation of message.Content uses byte-based
slicing which can cut multibyte characters mid-rune; change the logic in the
quotes.go truncation branch to operate on runes: compute rune length of
message.Content, check against maxQuoteLength as a rune count, convert
message.Content to []rune and slice to maxQuoteLength runes, then reassign the
string (e.g., using string([]rune(...)) ) and append "(以下略)"; update any other
uses of maxQuoteLength in this function to be rune-aware as well.
- Around line 11-13: quoteRegexStr currently contains `\\.` inside a raw string
which makes the regex look for a literal backslash before dots and thus never
matches real URLs; update the pattern in quoteRegexStr (used to build quoteRegex
via regexp.MustCompile) to use `\.` for the literal dots in the URL (e.g.,
change `https://q\\.trap\\.jp/messages/...` to
`https://q\.trap\.jp/messages/...`) so the regex matches actual URLs, then run
tests/usage paths that exercise quoteRegex to confirm quotes are detected.
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@internal/pkg/formatter/quotes.go`:
- Around line 33-48: The isUserAllowingQuotes function correctly implements the
approval logic (checks userID vs messageUserID, calls bot.GetUser and checks
messageUser.Bot) so no code changes are required; leave isUserAllowingQuotes and
its bot.GetUser/messageUser.Bot checks as-is.
- Around line 61-106: No change required: the FormatQuotedMessage function
already correctly enforces rune-based trimming (maxQuoteLength), checks channel
and user permissions (isChannelAllowingQuotes, isUserAllowingQuotes), and
handles errors and newline formatting; leave the implementation of
FormatQuotedMessage as-is and proceed with approving/merging the changes.
User description
BOT_GPT が呼び出された時にメッセージを引用していた場合、それを展開して LLM に渡すようにした
例えば
が
のように展開されるはず
ただし展開されるには次の条件のいずれかを満たす必要がある
さらに1つの引用メッセージで10000文字を超えた分は省略される
PR Type
enhancement, bug_fix
Description
引用メッセージを展開する機能を追加
キャッシュ機能を用いたチャンネルとユーザー情報の取得
引用メッセージのフォーマットと条件を修正
新しい依存関係の追加
Diagram Walkthrough
File Walkthrough
5 files
チャンネルパス取得のキャッシュ機能を追加ユーザー情報取得のキャッシュ機能を追加引用メッセージのフォーマット処理を追加引用メッセージのフォーマット処理を追加引用メッセージのフォーマットと条件を実装2 files
新しい依存関係を追加新しい依存関係のチェックサムを追加Summary by CodeRabbit
リリースノート
新機能
パフォーマンス改善