diff --git a/pkg/channels/discord.go b/pkg/channels/discord.go index ba02f7598..472b51c53 100644 --- a/pkg/channels/discord.go +++ b/pkg/channels/discord.go @@ -105,7 +105,7 @@ func (c *DiscordChannel) Send(ctx context.Context, msg bus.OutboundMessage) erro return nil } - chunks := utils.SplitMessage(msg.Content, 2000) // Discord hard limit: 2000 chars (prefers split at 1500 to leave room for code blocks) + chunks := utils.SplitMessage(msg.Content, 2000) // Split messages into chunks, Discord length limit: 2000 chars for _, chunk := range chunks { if err := c.sendChunk(ctx, channelID, chunk); err != nil { diff --git a/pkg/utils/message.go b/pkg/utils/message.go index 9ca49ba53..ed56da95b 100644 --- a/pkg/utils/message.go +++ b/pkg/utils/message.go @@ -7,9 +7,9 @@ import ( const defaultCodeBlockBuffer = 500 // SplitMessage splits long messages into chunks, preserving code block integrity. -// The maxLen parameter is the hard upper limit - no message will exceed this length. // The function prefers to split at maxLen - defaultCodeBlockBuffer to leave room for code blocks, // but may extend up to maxLen when needed to avoid breaking incomplete code blocks. +// Please refer to pkg/channels/discord.go for usage. func SplitMessage(content string, maxLen int) []string { var messages []string codeBlockBuffer := defaultCodeBlockBuffer @@ -41,7 +41,7 @@ func SplitMessage(content string, maxLen int) []string { if unclosedIdx >= 0 { // Message would end with incomplete code block - // Try to extend up to maxLen (hard limit, never exceed) to include the closing ``` + // Try to extend up to maxLen to include the closing ``` if len(content) > msgEnd { closingIdx := FindNextClosingCodeBlock(content, msgEnd) if closingIdx > 0 && closingIdx <= maxLen {