mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-19 10:15:01 +00:00
fix(channels): include display name in [From:] annotation for Telegram and WhatsApp
Telegram: senderLabel now includes full name alongside username, e.g. [From: @nguyennlt (Nguyễn Trần)] instead of just [From: @nguyennlt]. Also uses FirstName + LastName when no username is set. WhatsApp: add missing [From:] annotation — was the only channel not annotating sender identity for the LLM.
This commit is contained in:
1 parent
b38a078e70
commit
53932cf532
2 files changed
+12
-2
No files matched your search
@@ -226,9 +226,14 @@ func (c *Channel) handleMessage(ctx context.Context, update telego.Update) {
|
||||
}
|
||||
|
||||
// Compute sender label for group context (used in history + current message annotation)
|
||||
senderLabel := user.FirstName
|
||||
displayName := strings.TrimSpace(user.FirstName + " " + user.LastName)
|
||||
senderLabel := displayName
|
||||
if user.Username != "" {
|
||||
senderLabel = "@" + user.Username
|
||||
if displayName != "" {
|
||||
senderLabel = "@" + user.Username + " (" + displayName + ")"
|
||||
} else {
|
||||
senderLabel = "@" + user.Username
|
||||
}
|
||||
}
|
||||
|
||||
// --- Group mention gating (matching TS mentionGate logic) ---
|
||||
|
||||
@@ -274,6 +274,11 @@ func (c *Channel) handleIncomingMessage(msg map[string]any) {
|
||||
cc.EnsureContact(ctx, c.Type(), c.Name(), senderID, senderID, metadata["user_name"], "", peerKind, "user")
|
||||
}
|
||||
|
||||
// Annotate with sender identity so the agent knows who is messaging.
|
||||
if senderName := metadata["user_name"]; senderName != "" {
|
||||
content = fmt.Sprintf("[From: %s]\n%s", senderName, content)
|
||||
}
|
||||
|
||||
c.HandleMessage(senderID, chatID, content, media, metadata, peerKind)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user