better poll args

This commit is contained in:
eneller
2025-04-27 18:17:15 +02:00
parent cbc8a39d72
commit 4a5de95615

View File

@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"log" "log"
"os" "os"
"strings"
"time" "time"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
@@ -80,7 +79,7 @@ func initClient() (*whatsmeow.Client, *sqlstore.Container, waLog.Logger) {
} }
func main() { func main() {
var jidStr, header, optionsStr, text string var jidStr, header, text string
var message *waE2E.Message var message *waE2E.Message
var client *whatsmeow.Client var client *whatsmeow.Client
var container *sqlstore.Container var container *sqlstore.Container
@@ -122,12 +121,11 @@ func main() {
Arguments: []cli.Argument{ Arguments: []cli.Argument{
&cli.StringArg{Name: "jid", Destination: &jidStr}, // use id field of group &cli.StringArg{Name: "jid", Destination: &jidStr}, // use id field of group
&cli.StringArg{Name: "header", Destination: &header}, &cli.StringArg{Name: "header", Destination: &header},
&cli.StringArg{Name: "options", Destination: &optionsStr}, &cli.StringArgs{Name: "options", Min: 2, Max: -1},
}, },
Action: func(ctx context.Context, cmd *cli.Command) error { Action: func(ctx context.Context, cmd *cli.Command) error {
// parse JID // parse JID
var options = strings.Fields(optionsStr) message = client.BuildPollCreation(header, cmd.StringArgs("options"), 1)
message = client.BuildPollCreation(header, options, 1)
return nil return nil
}, },
}, },