mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-13 11:07:31 +08:00
telegram streaming: finalize placeholder when response suppressed
This commit is contained in:
@@ -324,6 +324,9 @@ func (al *AgentLoop) processInbound(ctx context.Context, msg bus.InboundMessage)
|
|||||||
suppressed = true
|
suppressed = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if msg.Channel == "telegram" && suppressed {
|
||||||
|
al.bus.PublishOutbound(bus.OutboundMessage{Channel: msg.Channel, ChatID: msg.ChatID, Action: "finalize"})
|
||||||
|
}
|
||||||
al.audit.Record(trigger, msg.Channel, msg.SessionKey, suppressed, err)
|
al.audit.Record(trigger, msg.Channel, msg.SessionKey, suppressed, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ type TelegramChannel struct {
|
|||||||
|
|
||||||
func (c *TelegramChannel) SupportsAction(action string) bool {
|
func (c *TelegramChannel) SupportsAction(action string) bool {
|
||||||
switch strings.ToLower(strings.TrimSpace(action)) {
|
switch strings.ToLower(strings.TrimSpace(action)) {
|
||||||
case "", "send", "stream", "edit", "delete", "react":
|
case "", "send", "stream", "finalize", "edit", "delete", "react":
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
@@ -268,6 +268,17 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
|
|||||||
safeCloseSignal(stop)
|
safeCloseSignal(stop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if action == "finalize" {
|
||||||
|
if stop, ok := c.stopThinking.LoadAndDelete(msg.ChatID); ok {
|
||||||
|
safeCloseSignal(stop)
|
||||||
|
}
|
||||||
|
if pID, ok := c.placeholders.LoadAndDelete(msg.ChatID); ok {
|
||||||
|
delCtx, cancel := withTelegramAPITimeout(ctx)
|
||||||
|
_ = c.bot.DeleteMessage(delCtx, &telego.DeleteMessageParams{ChatID: chatID, MessageID: pID.(int)})
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if action != "send" && action != "stream" {
|
if action != "send" && action != "stream" {
|
||||||
return c.handleAction(ctx, chatIDInt, action, msg)
|
return c.handleAction(ctx, chatIDInt, action, msg)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user