Remove duplicate truncate functions, reuse utils.Truncate
Multiple packages had their own private truncate implementations: - channels/telegram.go: truncateString (byte-based, no "...") - channels/dingtalk.go: truncateStringDingTalk (byte-based, no "...") - voice/transcriber.go: truncateText (byte-based, with "...") All three are functionally equivalent to the existing utils.Truncate, which already handles rune-safe truncation and appends "..." correctly. Replace all private copies with utils.Truncate and delete the dead code.
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/sipeed/picoclaw/pkg/bus"
|
||||
"github.com/sipeed/picoclaw/pkg/config"
|
||||
"github.com/sipeed/picoclaw/pkg/logger"
|
||||
"github.com/sipeed/picoclaw/pkg/utils"
|
||||
)
|
||||
|
||||
type FeishuChannel struct {
|
||||
@@ -165,7 +166,7 @@ func (c *FeishuChannel) handleMessageReceive(_ context.Context, event *larkim.P2
|
||||
logger.InfoCF("feishu", "Feishu message received", map[string]interface{}{
|
||||
"sender_id": senderID,
|
||||
"chat_id": chatID,
|
||||
"preview": truncateString(content, 80),
|
||||
"preview": utils.Truncate(content, 80),
|
||||
})
|
||||
|
||||
c.HandleMessage(senderID, chatID, content, nil, metadata)
|
||||
|
||||
Reference in New Issue
Block a user