The first time I write telegram bot. He has some commands. Assume:
/ command1, / command2, text, if the command entered is not listed
A handler was made for them (interaction using webhuk).
Command1 is working properly.
And on command2, the handler must select a randomized line from a text file and return it. I do with this code:
$a = file('./file.txt'); $preload_text = $a[array_rand($a)]; sendMessage($chat_id, $preload_text); But in telegram does not return anything when you enter the command2.
Made a new test.php file in the same directory as the handler and shoved code into it:
$a = file('./file.txt'); echo $a[array_rand($a)]; I open site.ru/test.php in the browser - everything works correctly.
If in $preload_text just set a string, then it returns correctly to the telegrams
What is the problem?