The response of the bot to the words in the sentences?

How to make a bot that would respond to specific words in sentences of any length? A bot written in php. Will be good if will throw a code
April 7th 20 at 10:53
3 answers
April 7th 20 at 10:55
Solution
If easier, you can use the banal strpos, which will return you to "not null" if the string is present you need the substring.
$pos = strpos('bot responded to specific words in sentences', 'bot');
if ($pos === false) {
 echo "Substring not found";
} else {
 echo "Substring found";
}
it is necessary to take into account user input, that is, it is not known which proposal will introduce the user - Parker_Schmidt commented on April 7th 20 at 10:58
@Parker_Schmidt, uh, so substitute... - Henri_Stros commented on April 7th 20 at 11:01
Logical =\ - Parker_Schmidt commented on April 7th 20 at 11:04
and you don't know how to do user input in the bot? - Parker_Schmidt commented on April 7th 20 at 11:07
@Parker_Schmidt, so you need to catch events through longpollserver or using the callback api vk. Open the documentation and read. There are all described. - Henri_Stros commented on April 7th 20 at 11:10
thank you - Parker_Schmidt commented on April 7th 20 at 11:13
April 7th 20 at 10:57
preg_match()
April 7th 20 at 10:59

Find more questions by tags PHPVKontakteBots