M
M
mrisid2019-10-13 19:11:22
PHP
mrisid, 2019-10-13 19:11:22

The bot sends messages by itself, what should I do!?

Everything worked perfectly, but suddenly the bot started to glitch, after I transferred it to a new host, it sends 1 message, as well as all sorts of messages by itself, help good people!

<?php

include "vk_api.php";  // vk_api addon


const VK_KEY = "";  // Token Group
const ACCESS_KEY = "";  // VK Group Key
const VERSION = ""; // API Version


// buttons
const BTN_1 = [["command" => 'btn_1'], "Проблемы с модпаком", "green"];
const BTN_2 = [["command" => 'btn_2'], "Проблемы с IP", "green"];
const BTN_3 = [["command" => 'btn_3'], "Проблемы с сервером", "green"];
const BTN_5 = [["command" => 'btn_5'], "Проблемы с сайтом", "green"];
const BTN_6 = [["command" => 'btn_6'], "Задать вопрос", "green"];
const BTN_7 = [["command" => 'btn_7'], "Не помогло", "red"];


$vk = new vk_api(VK_KEY, VERSION); 
$data = json_decode(file_get_contents('php://input')); 

if ($data->type == 'confirmation') { 
    exit(ACCESS_KEY); 
}
$vk->sendOK(); 
// vars
$peer_id = $data->object->peer_id;// Id user
$message = $data->object->text; // text user
// vars

if ($data->type == 'message_new') { // create check new message
    if($message == 'Проблема') {
$vk->sendButton($peer_id, "Выберите к чему относится ваша проблема 	&#128421;", [[BTN_1], [BTN_2], [BTN_3], [BTN_5], [BTN_6], [BTN_7]]);

        }
    if($message == 'проблема') {
$vk->sendButton($peer_id, "Выберите к чему относится ваша проблема 	&#128421;", [[BTN_1], [BTN_2], [BTN_3], [BTN_5], [BTN_6], [BTN_7]]);

        }
        


    if($message == 'Проблемы с модпаком') {
$vk->sendButton($peer_id, "Временно не доступно &#128224;");
    exit;
        }
    if($message == 'Проблемы с IP') {
$vk->sendButton($peer_id, "Временно не доступно &#128224;");
  exit;
        }
        
    if($message == 'Проблемы с сервером') {
$vk->sendButton($peer_id, "Временно не доступно &#128224;");
  exit;
        }
        
    if($message == 'Проблемы с сайтом') {
$vk->sendButton($peer_id, "Временно не доступно &#128224;");
  exit;
        }
        
    if($message == 'Задать вопрос') {
$vk->sendButton($peer_id, "Задайте интересующий вас вопрос,\nсотрудники тех.поддержки обязательно вам ответят&#128172;");
  exit;
        }
        
    if($message == 'Не помогло') {
$vk->sendButton($peer_id, "Опишите вашу проблему,\nсотрудники тех.поддержки обязательно вам ответят&#128172;");
  exit;
        }
}

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
2
2bllk, 2019-10-13
@2bllk

The problem is that if there are any problems when accepting a response from your server by the VK server, then VK can send several requests to the server if it does not receive a successful response from your server. And your server dutifully accepts the duplicated request and sends a message. This request can easily arrive in a few weeks. Therefore, when sending a message, you must use the parameter that is highlighted in the attached screenshot.
PS: I hope it will work for you (at first everything worked for me, and then something somehow didn’t work out)5da36f80bdde1145673890.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question