1
I would like to know how to create an activator - or Trigger - in PHP but I don’t know where to start.
I wanted to make the user type, for example, "nato stack". PHP would recognize the first term "NATO" and play as a result "Sierra-Tango-Alpha-Charlie-Kilo".
I did a search and this is called Trigger, or Activator.
My model for creation is this: https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Phonetic.pm
Issue 1:
I got it from here with PHP:
<?php
$busca = strtolower('nato StACKoverFLoW');
$nato = str_replace("nato", "", $busca);
$trans = array("a" => "Alfa ", "b" => "Bravo ", "c" => "Charlie ", "d" => "Delta ", "e" => "Echo ", "f" => "Foxtrot ", "g" => "Golf ", "h" => "Hotel ", "i" => "India ", "j" => "Juliet ", "k" => "Kilo ", "l" => "Lima ", "m" => "Mike ", "n" => "November ", "o" => "Oscar ", "p" => "Papa ", "q" => "Quebec ", "r" => "Romeo ", "s" => "Sierra ", "t" => "Tango ", "u" => "Uniform ", "v" => "Victor ", "w" => "Whiskey ", "x" => "Xray ", "y" => "Yankee ", "z" => "Zulu ", "1" => "One ", "2" => "Two ", "3" => "Three ", "4" => "Four ", "5" => "Five ", "6" => "Six ", "7" => "Seven ", "8" => "Eight ", "9" => "Nine ", "0" => "Zero");
echo strtr($nato, $trans);
?>
This repository you passed calls this "Instant Answers"
– Édipo Costa Rebouças
@That’s right! It’s called Goodie Instant Answers.
– hsbpedro
a not very robust solution is to test several regular expressions, one for each command, and stop when any "marry".
– Édipo Costa Rebouças