Answer the question
In order to leave comments, you need to log in
Is it okay to develop bots this way?
I have a simple bot. Question answer. No contexts, sessions, etc. My code looks something like this:
<?php
if ($query === 'привет') {
echo 'Привет';
} elseif ($query === 'фыввфывфв') {
echo 'Ага';
} elseif (preg_match('//', $query) {
echo 'Ясно';
} else {
echo 'Я не понял тебя';
}
Answer the question
In order to leave comments, you need to log in
It's better to store words in the same json + one class that will process all this and give the result
.
1. See switch-case
2. Use recursive descent through the branches of the best matches to issue (display / echo) the desired answer options.
I advise you to try the comparison through the Stumper API .
By the highest percentage of coincidence with the phrases you have - give the desired answer.
Of course, GC.
You should at least use regular expressions, because 'Hello' !== 'hello!'.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question