Написал код для бота в вк. На сообщение test он должен отвечать hey 1 раз. Вместо этого через некоторое время он пишет hey еще несколько раз. Помогите пожалуйста. Бот работает через Callback API. PHP: <?php if (!isset($_REQUEST)) { return;} $searchres = ''; $confirmation_token = ''; $token = ''; $group = ''; $random = 24; $sendres = ''; function Send ($text,$idsend) { global $sendres,$token,$group; $sendres = file_get_contents('https://api.vk.com/method/messages.send?peer_id='.$idsend.'&message='.urlencode($text).'&access_token='.$token.'&group_id='.$group.'&v=5.92&random_id='.$random);} $resname = ''; function Names($NamedId, $N1, $N2, $Nform) { global $token,$group,$resname; $Nameref = json_decode(file_get_contents('https://api.vk.com/method/User.get?access_token='.$token.'&group_id='.$group.'&v=5.92&user_ids='.$NamedId.'&name_case='.$Nform)); if ($N1 == 1) {$resname = $Nameref['response'][0]['first_name'];} if ($N2 == 1) {if ($resname != '') {$resname = $resname.' ';} $resname = $resname.$Nameref['response'][0]['last_name'];}} $data = json_decode(file_get_contents('php://input')); switch ($data->type) { case 'confirmation': echo $confirmation_token; break; case 'message_new': $id = $data->object->peer_id; $mes = $data->object->text; $Aid = $data->object->from_id; $basecount = 0; while ($basecount <= count($base['local'])) /*tester func*/ { $searchres = $searchres.key($base['local']); $basecount = $basecount + 1; next($base['local']);} if (strpos($searchres,$Aid) == False) { array_push ($base['local'],'id'.$Aid); $ATid = 'id'.$Aid; $base['local'][$ATid] = ['party'=>['invite'=>0,'request','invited'=>0]];} if (strpos($mes, '/b') == 0) { $a = substr($mes, 3); Send ('',$id);} if ($mes == 'test') { Send ("hey",$id); } echo 'ok'; break;} ?>
у тебя же функция Send два раза в коде вызвается. Отформатируй код у себя нормально, ты сам уже не видишь где что