My question is this, I'm doing a Telegram bot with user help in various cases. I would like to capture a piece of the message that you send me to use it as a variable, that is:
switch($mensaje)
case '/tiempo Madrid':
$ciudad="Madrid";
$horas=FALSE;
getTiempo($chatId,$ciudad,$horas);
break;
In this case I would like not to have to write the city directly in the case, but to make a kind of /tiempo $ciudad
, whose variable $ciudad
can use to call the function getTiempo()
and thus not have to write one by one all the cities of the world as different cases.
That is, something like this:
switch($mensaje)
case '/tiempo $ciudad':
$horas=FALSE;
getTiempo($chatId,$ciudad,$horas);
break;
Thank you very much for the help.