Skip to content

fix: Discord でbotのセリフを content に表示する (#95)#98

Merged
limit7412 merged 1 commit into
masterfrom
fix/discord-serif-in-content
Jul 14, 2026
Merged

fix: Discord でbotのセリフを content に表示する (#95)#98
limit7412 merged 1 commit into
masterfrom
fix/discord-serif-in-content

Conversation

@limit7412

Copy link
Copy Markdown
Owner

概要

issue #95 を解決する。Discord 投稿時に botのセリフ([Issue] 更新があったみたいです。確認してみましょう! 等の pretext)が「消えている」ように見える問題を修正する。

原因

  • Slack モードではセリフ(pretext)は attachment の pretext として カードの外=botの発言行 に表示される。
  • Discord モードでは embed に pretext 相当の欄が無いため、セリフを embed の description(コメント本文)に結合して入れていた。つまりセリフは embed カードの中 にしか出ず、botの発言として表示されない。
  • さらにメンション時の content(botの発言行)は @everyone のみを出力しており、MENTION_REASONS が広く実通知はほぼメンション扱いとなるため、発言行には @everyone しか出ずセリフが消えたように見えていた

修正内容 (src/discord/models.cr)

  1. セリフ(pretext)を Post の content に出力 し、Slack と同様「botの発言行」として embed の外に表示する
    • メンション時は content 先頭に @everyone を添える(@everyone\n<セリフ>
    • 1投稿に複数 embed をまとめる場合、チャンク内の pretext を uniq(順序保持)して結合
    • content の 2000 文字上限(CONTENT_LIMIT)で truncate
  2. 二重表示を避けるため description からは pretext を外し、コメント本文のみとする
  3. 送信ペイロード(Post#to_json)を print_log で出力し、表示の切り分け(description / footer が意図通りか)を CloudWatch で確認できるようにする

表示イメージ(実ペイロード)

{"content":"@everyone\n[Issue] 更新があったみたいです。確認してみましょう!","embeds":[{"title":"Spurious failure","description":"コメント本文です","color":11129077,"footer":{"text":"octocat/Hello-World"}},{"title":"Another","description":"別コメント"}]}

セリフが content(botの発言行)に出て、embed の description はコメント本文のみになった。同一チャンク内の同じセリフは1行にまとめられる。

フッターについて

Discord embed の footer.text は仕様上プレーンテキストのみ(リンク・markdown 不可)で、現実装もリポジトリ名を文字列として送っており、そもそもリンクは設定していない。表示欠落は Discord クライアント側の描画の可能性があり、実害があれば別 issue に切り出す方針(本 PR のスコープ外)。

テスト

  • spec/discord/models_spec.cr を更新(content へのセリフ出力 / mention 併記 / description から pretext 除外 / uniq / truncate)
  • crystal spec 37 examples 0 failures / ameba 0 failures / crystal build src/main.cr 成功

Closes #95

🤖 Generated with Claude Code

Discord モードでは embed に pretext 相当の欄が無く、セリフ(pretext)を
embed の description に埋め込んでいたため、Slack のように「botの発言」として
表示されず消えたように見えていた。さらにメンション時は content に @everyone
しか出ず、セリフが出なかった。

- pretext を Post の content に出力し、Slack 同様「botの発言行」として表示
  - メンション時は content 先頭に @everyone を添える
  - チャンク内で重複するセリフは uniq でまとめ、CONTENT_LIMIT(2000)で truncate
- 二重表示を避けるため description からは pretext を外しコメント本文のみに
- 送信ペイロードを print_log で出力し表示の切り分けをしやすくする
- spec/discord/models_spec.cr を更新

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors Discord post formatting by moving the bot's serif (pretext) from the embed's description into the post's main content to prevent double-display issues. It also adds logic to prepend channel-wide mentions, de-duplicate repeated pretexts, truncate content to Discord's limit, and log the outgoing payload for debugging. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@limit7412 limit7412 merged commit f9490d2 into master Jul 14, 2026
2 checks passed
@limit7412 limit7412 deleted the fix/discord-serif-in-content branch July 14, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discord投稿時にbotのセリフが消えている

1 participant