My question is the following, I am making a Telegram bot with help to the user in various cases. I would like to capture a piece of the message that it sends 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 I $ciudad
can use to call the function getTiempo()
and thus not have to write all the cities of the world one by one 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.