mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-13 17:20:31 +08:00
add message edit/delete/react flow and incremental process poll logs
This commit is contained in:
@@ -532,11 +532,17 @@ func (c *TelegramChannel) handleAction(ctx context.Context, chatID int64, action
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
return c.bot.DeleteMessage(delCtx, &telego.DeleteMessageParams{ChatID: telegoutil.ID(chatID), MessageID: messageID})
|
return c.bot.DeleteMessage(delCtx, &telego.DeleteMessageParams{ChatID: telegoutil.ID(chatID), MessageID: messageID})
|
||||||
case "react":
|
case "react":
|
||||||
|
reactCtx, cancel := withTelegramAPITimeout(ctx)
|
||||||
|
defer cancel()
|
||||||
emoji := strings.TrimSpace(msg.Emoji)
|
emoji := strings.TrimSpace(msg.Emoji)
|
||||||
if emoji == "" {
|
if emoji == "" {
|
||||||
return fmt.Errorf("emoji required for react action")
|
return fmt.Errorf("emoji required for react action")
|
||||||
}
|
}
|
||||||
return fmt.Errorf("telegram react action not supported by current telego version")
|
return c.bot.SetMessageReaction(reactCtx, &telego.SetMessageReactionParams{
|
||||||
|
ChatID: telegoutil.ID(chatID),
|
||||||
|
MessageID: messageID,
|
||||||
|
Reaction: []telego.ReactionType{&telego.ReactionTypeEmoji{Emoji: emoji}},
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported telegram action: %s", action)
|
return fmt.Errorf("unsupported telegram action: %s", action)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,9 +58,18 @@ func (t *ProcessTool) Execute(ctx context.Context, args map[string]interface{})
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
off := toInt(args["offset"])
|
||||||
|
lim := toInt(args["limit"])
|
||||||
|
if lim <= 0 {
|
||||||
|
lim = 1200
|
||||||
|
}
|
||||||
|
if off < 0 {
|
||||||
|
off = 0
|
||||||
|
}
|
||||||
|
chunk, _ := t.m.Log(sid, off, lim)
|
||||||
s.mu.RLock()
|
s.mu.RLock()
|
||||||
defer s.mu.RUnlock()
|
defer s.mu.RUnlock()
|
||||||
resp := map[string]interface{}{"id": s.ID, "running": s.ExitCode == nil, "started_at": s.StartedAt.Format(time.RFC3339)}
|
resp := map[string]interface{}{"id": s.ID, "running": s.ExitCode == nil, "started_at": s.StartedAt.Format(time.RFC3339), "log": chunk, "next_offset": off + len(chunk)}
|
||||||
if s.ExitCode != nil {
|
if s.ExitCode != nil {
|
||||||
resp["exit_code"] = *s.ExitCode
|
resp["exit_code"] = *s.ExitCode
|
||||||
resp["ended_at"] = s.EndedAt.Format(time.RFC3339)
|
resp["ended_at"] = s.EndedAt.Format(time.RFC3339)
|
||||||
|
|||||||
Reference in New Issue
Block a user