Ceci est une ancienne révision du document !
Donne moi la température
Ce script permet de donner la température d'une ville si elle est renseignée. La première lettre du nom de la ville doit être en majuscule.
Script
// Variables $messageTemperature = "init"; $scenario->setData("messageTemperature", $messageTemperature); $action = "init"; $town = "init"; $value_temperature = "init"; $object = "init"; $cmd = "init"; // Get tags todo from interaction $action = $scenario->getTags()['#todo#']; $action = ucfirst(strtolower($action)); // Get tags town from interaction. If town's name contain ' delete it. This part is according with your nomenclature town's name $town = $scenario->getTags()['#town#']; if (strpos($town, "'") > 0) { $pos = strpos($town, "'"); $town = ucfirst(substr($town, 0, $pos)).ucfirst(substr($town, $pos+1, strlen($town))); } else { $town = ucfirst(strtolower($town)); } // Get value of $action from $town $object = "#[".$town."][".$town."][".$action."]#"; $cmd = cmd::byString($object); if (gettype($cmd) == "object") { $value_temperature = $cmd->execCmd(); } // Make return message if (is_numeric($value_temperature)) { $messageTemperature = "Actuellement la température à ".$town." est de ".$value_temperature." °c."; } $scenario->setData("messageTemperature", $messageTemperature);