mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-08 01:37:30 +08:00
improve reply-tag parsing with current message fallback and outbound reply metadata
This commit is contained in:
@@ -205,7 +205,7 @@ func (al *AgentLoop) Run(ctx context.Context) error {
|
|||||||
if shouldDropNoReply(response) {
|
if shouldDropNoReply(response) {
|
||||||
suppressed = true
|
suppressed = true
|
||||||
} else {
|
} else {
|
||||||
clean, replyToID := parseReplyTag(response)
|
clean, replyToID := parseReplyTag(response, msg.Metadata["message_id"])
|
||||||
if al.shouldSuppressOutbound(msg, clean) {
|
if al.shouldSuppressOutbound(msg, clean) {
|
||||||
suppressed = true
|
suppressed = true
|
||||||
} else {
|
} else {
|
||||||
@@ -931,7 +931,7 @@ func shouldDropNoReply(text string) bool {
|
|||||||
return strings.EqualFold(t, "NO_REPLY")
|
return strings.EqualFold(t, "NO_REPLY")
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseReplyTag(text string) (content string, replyToID string) {
|
func parseReplyTag(text string, currentMessageID string) (content string, replyToID string) {
|
||||||
t := strings.TrimSpace(text)
|
t := strings.TrimSpace(text)
|
||||||
if !strings.HasPrefix(t, "[[") {
|
if !strings.HasPrefix(t, "[[") {
|
||||||
return text, ""
|
return text, ""
|
||||||
@@ -946,6 +946,8 @@ func parseReplyTag(text string) (content string, replyToID string) {
|
|||||||
content = strings.TrimSpace(t[end+2:])
|
content = strings.TrimSpace(t[end+2:])
|
||||||
if strings.HasPrefix(tag, "reply_to:") {
|
if strings.HasPrefix(tag, "reply_to:") {
|
||||||
replyToID = strings.TrimSpace(rawTag[len("reply_to:"):])
|
replyToID = strings.TrimSpace(rawTag[len("reply_to:"):])
|
||||||
|
} else if strings.HasPrefix(tag, "reply_to_current") {
|
||||||
|
replyToID = strings.TrimSpace(currentMessageID)
|
||||||
}
|
}
|
||||||
return content, replyToID
|
return content, replyToID
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
|
|||||||
if markup != nil {
|
if markup != nil {
|
||||||
sendParams.WithReplyMarkup(markup)
|
sendParams.WithReplyMarkup(markup)
|
||||||
}
|
}
|
||||||
|
_ = strings.TrimSpace(msg.ReplyToID) // reserved for provider-level reply threading support
|
||||||
|
|
||||||
sendCtx, cancelSend := withTelegramAPITimeout(ctx)
|
sendCtx, cancelSend := withTelegramAPITimeout(ctx)
|
||||||
_, err = c.bot.SendMessage(sendCtx, sendParams)
|
_, err = c.bot.SendMessage(sendCtx, sendParams)
|
||||||
|
|||||||
Reference in New Issue
Block a user