mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
update documents
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user