
Parse a text message into command and arguments (Whapi helper)
Source:R/webhook.R
whapi_parse_command.RdSplits an incoming text (usually from a WhatsApp message) into a command
(the first token, starting with /) and its associated arguments.
Supports collapsing arguments into a single string or preserving them as
a character vector.
Value
A list with two elements:
commandThe command string (first token), trimmed (e.g.
"/groe").argumentsThe arguments, either collapsed as a single string (default) or as a character vector, depending on
collapse_args.
Examples
whapi_parse_command("/groe ajuda")
#> $command
#> [1] "/groe"
#>
#> $arguments
#> [1] "ajuda"
#>
#> $command
#> [1] "/groe"
#>
#> $arguments
#> [1] "ajuda"
whapi_parse_command("/groe nome empresa", collapse_args = FALSE)
#> $command
#> [1] "/groe"
#>
#> $arguments
#> [1] "nome" "empresa"
#>
#> $command
#> [1] "/groe"
#>
#> $arguments
#> [1] "nome" "empresa"