Skip to content

How to append command with parameters? #68

Answered by punyflash
mko543 asked this question in Q&A
Discussion options

You must be logged in to vote

You can create a method to extract arguments from your command:

protected function arguments()
{
    $command = array_filter(explode(' ', $this->update->message()->text));
    array_shift($command);
    return array_values($command);
}

This is the simplest way, but If you need more complex arguments, you may add a custom algorithm using regex or other.

Then just use this method (for example, if command was /generate 5):

[$days] = $this->arguments();
// $days == 5

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mko543
Comment options

@mko543
Comment options

Answer selected by mko543
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants