]> git.giacomolli.uk - onechat/blobdiff - tools.go
Reflow the comments of promptTools and terminal
[onechat] / tools.go
index b20b3ace6f22bf38b40b4681488e584cdc62c04e..7640dee9f3ff18c7ecfa456967c3621239cd370c 100644 (file)
--- 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 {