A
A
Alex Blinov2019-12-12 18:23:22
PHP
Alex Blinov, 2019-12-12 18:23:22

How to remove the text mentioning the bot from the Vkontakte message?

There is a bot in php. When mentioned in a conversation, the text of the message is taken and sent upside down. The mention text is also taken, but I don't need it. Tell me how to fix it, or just remove the first characters through a crutch?
5df25b650e792844268786.png
Main parts of the code:

$id = $data->object->from_id; 
$peer_id = $data->object->peer_id; 
$message = $data->object->text;
if ($data->type == 'message_new') {  
 $vk->sendMessage($peer_id, $message));  
 }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
#
#yamynginx, 2019-12-12
@muxui

str_replace()

L
Lev Zabudkin, 2019-12-14
@zabudkin

There is little information about what the bot message looks like.
If everything is in the @ symbol (dog), then simply:
$id = $data->object->from_id;
$peer_id = $data->object->peer_id;
$message = $data->object->text;
$peer_id = str_replace("what are we looking for",what are we changing to",$peer_id );
if ($data->type == 'message_new') {
$vk->sendMessage($peer_id, $message));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question