I
I
Ivan Kutsenko2019-11-09 12:56:00
PHP
Ivan Kutsenko, 2019-11-09 12:56:00

The bot stopped executing the exclusion command, what's wrong?

The bot stopped executing the exclusion command
The code itself

if($cmd == "вис"){
    if($vk->isAdmin($peer_id, $id)){
      if($reply_author == ''){
        $vk->sendMessage($peer_id, "@id{$peer_id} ({$first_name}), Вы не указали человека, которого нужно исключить (перешлите любое его сообщение)");
      }else{
        $userInfo_reply = $vk->request("users.get", ["user_ids" => $reply_author]);
        $first_name_reply = $userInfo[0]['first_name'];
        $vk->sendMessage($peer_id, "@id{$reply_author} ({$first_name_reply}), Мы неоднократно выносили предупреждения, которые вы игнорировали. Теперь придется попрощаться.");
        $vk->request('messages.removeChatUser', ['chat_id' => $chat_id, 'member_id' => $reply_author]);
      }
    }else{
      $vk->sendMessage($peer_id, "Ты не админ");
    }
  }

Everything was fine before, I don't know what happened. If you need the full code of the bot, then here it is:
<?php
include "vk_api.php";

const VK_KEY = "";
const ACCESS_KEY = "";
const VERSION = "5.81";

$vk = new vk_api(VK_KEY, VERSION);
$data = json_decode(file_get_contents('php://input'));
//print_r($data);
if ($data->type == 'confirmation') {
    exit(ACCESS_KEY);
}
$vk->sendOK();
// ---------- Переменные ----------
$peer_id = $data->object->peer_id;
$id = $data->object->from_id;
$chat_id = $peer_id - 2000000000;
// ---------- Сообщение ----------
$message = $data->object->text;
$messages = explode(" ", $message);
$cmd = mb_strtolower(str_replace(array("/", "!"), "", $messages[0]));
$args = array_slice($messages, 1);
// ---------- Другое ----------
$reply_message = $data->object->reply_message;
$reply_author = $data->object->reply_message->from_id;
$chat_act = $data->object->action;
$fwd_messages = $object['fwd_messages'];
if(empty($fwd_messages) && !empty($reply_message)) {
  array_push($fwd_messages, $reply_message);
}
if(empty($reply_message) && !empty($fwd_messages)) {
  $reply_message = $fwd_messages[0];
}
$дата = date("d.m.Y  H:i");
// СООБЩЕНИЕ ПРОВЕРИЛИ ДА
if($data->type == 'message_new'){
  if($cmd == 'бот'){
    $vk->sendMessage($peer_id, "Привет");
  }
  if($cmd == 'дата'){
    $vk->sendMessage($peer_id, "{$дата}");
  }
  if($cmd == "вис"){
    if($vk->isAdmin($peer_id, $id)){
      if($reply_author == ''){
        $vk->sendMessage($peer_id, "@id{$peer_id} ({$first_name}), Вы не указали человека, которого нужно исключить (перешлите любое его сообщение)");
      }else{
        $userInfo_reply = $vk->request("users.get", ["user_ids" => $reply_author]);
        $first_name_reply = $userInfo[0]['first_name'];
        $vk->sendMessage($peer_id, "@id{$reply_author} ({$first_name_reply}), Мы неоднократно выносили предупреждения, которые вы игнорировали. Теперь придется попрощаться.");
        $vk->request('messages.removeChatUser', ['chat_id' => $chat_id, 'member_id' => $reply_author]);
      }
    }else{
      $vk->sendMessage($peer_id, "Ты не админ");
    }
  }
    if(implode(' ', $messages) == 'пуш'){
    if($vk->isAdmin($peer_id, $id)){
      $get_members = $vk->request('messages.getConversationMembers', ['peer_id' => $peer_id]); // Получили список пользователей беседы
      foreach ($get_members['profiles'] as $member) { // Прошли по массиву для регистрации пользователей по их id
        $user_id = $member['id']; // Получили id пользоавтеля
        $allUsers .= "@id{$user_id} \n";
      }
      $vk->sendMessage($peer_id, "{$allUsers}");
    }else{
      $vk->sendMessage($peer_id, "У вас не достаточно прав!");
    }
  }
}

Z.Y. I'm just asking for help, because there is a main bot with 600 lines, the same thing happened to him

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question