X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/38a9b0502a1ccefc6ccb3472c4a21805b222caa6..6e7c7f3d47f086b9d59fe40b91fb071e1528684e:/tools.go?ds=inline diff --git a/tools.go b/tools.go index b20b3ac..7640dee 100644 --- a/tools.go +++ b/tools.go @@ -162,6 +162,15 @@ func (b *Toolbox) run(ctx context.Context, name, arguments string) string { case err == nil: output, err = b.whatsapp.Find(ctx, args.Name) } + case "whatsapp_send": + var args ToolWhatsAppSendArguments + err = toolDecodeArguments(arguments, &args) + switch { + case b.whatsapp == nil: + err = fmt.Errorf("unknown tool %q", name) + case err == nil: + output, err = b.whatsapp.Send(ctx, args.ID, args.Chat, args.Text) + } default: err = fmt.Errorf("unknown tool %q", name) } @@ -408,6 +417,13 @@ type ToolWhatsAppFindArguments struct { Name string `json:"name"` } +// ToolWhatsAppSendArguments are the arguments of whatsapp_send. +type ToolWhatsAppSendArguments struct { + ID string `json:"id"` + Chat string `json:"chat"` + Text string `json:"text"` +} + // ToolHeadTail keeps the first and the last toolClipBytes bytes written to it, // and counts the bytes between them that it drops. type ToolHeadTail struct {