Files
Memoh/internal/channel/adapters/common/logging.go
T
BBQ 3739def43f fix(text): avoid breaking UTF-8 during truncation
Use rune-aware truncation for user-facing text and log previews so multibyte content is not corrupted in memory context, Telegram messages, or diagnostics.
2026-03-09 12:43:57 +08:00

19 lines
428 B
Go

// Package common provides shared utilities for channel adapters.
package common
import (
"strings"
"github.com/memohai/memoh/internal/textutil"
)
// SummarizeText returns a truncated preview of the text, limited to 120 characters.
func SummarizeText(text string) string {
value := strings.TrimSpace(text)
if value == "" {
return ""
}
const limit = 120
return textutil.TruncateRunesWithSuffix(value, limit, "...")
}