D
D
Danissimk02018-07-07 01:55:57
PHP
Danissimk0, 2018-07-07 01:55:57

How to make a bot that either answers a question clogged in the code, or does not read the PM of the group?

Tell me how to make a bot in PHP, which will be given certain commands. If the user sends this command to the VK chat, the bot answers him, and if this command is absent, then he does not read the PM at all.
For a group in VK you need. Maybe someone did something similar and left the code. Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
ymer, 2018-07-07
@dnulled

example from VK docs
switch in php docs
conditions in php docs

P
p1ter, 2018-07-10
@p1ter

Try not to ask him the answer if there is no command.
for example

$message = $user_message;   // сообщение пользователя
if($message == '%команда%'){
$answer = '%ответ на команду%';
}
else{ 
$answer = '';    // на самом деле можно обойтись без этого, переменная в любом случае ничего содержать не будет
}

If the message is empty, then VK will not send it.
And do not forget to ask the admin to allow the bot to read all messages.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question