Answer the question
In order to leave comments, you need to log in
(Bot Adds extra characters in conversation) VK API PHP?
Hello, I am writing a bot for VK, there was a problem. created a keyboard, tested in PM, everything is ok, when added to a group, when the bot is pressed, it adds the value [club0xxxxxxxx|@group_link] text, when writing to the bot in PM, this is not the case, that is, the user presses the keyboard and this additional value is sent, I would like to remove it, does anyone know how to proceed?
I press the button
Handler code
<?php
error_reporting(0);
include 'bot_cfg.php';
include 'bot_functions.php';
if (!isset($_REQUEST)) return;
$data = json_decode(file_get_contents('php://input'));
if (strcmp($data->secret, $brawlerBot['guard_key']) !== 0 && strcmp($data->type, 'confirmation') !== 0) return;
switch ($data->type) {
case 'confirmation':
echo $brawlerBot['confirmation'];
break;
case 'message_reply':
header('HTTP/1.1 200 OK');
echo('ok');
break;
case 'message_new':
$userId = $data->object->peer_id;
$from = $data->object->from_id;
$userInfo = json_decode(file_get_contents("https://api.vk.com/method/users.get?user_ids={$userId}&v=5.8&access_token={$brawlerBot['api_key']}"));
$uInfo = [ 'name' => $userInfo->response[0]->first_name, 'family' => $userInfo->response[0]->last_name ];
$fromFunction = sendMessage($mysqli, $data->object->text, $uInfo, $userId, $lang, $data->object->payload,$from);
$request_params = [
'random_id' => generateRandomId(),
'message' => $fromFunction[0],
'peer_id' => $userId,
'access_token' => $brawlerBot['api_key'],
'v' => '5.80',
'keyboard' => $fromFunction[1],
];
$get_params = http_build_query($request_params);
file_get_contents('https://api.vk.com/method/messages.send?'.$get_params);
//file_put_contents('logs/mylog.txt', serialize($request_params));
header('HTTP/1.1 200 OK');
echo('ok');
break;
default:
header('HTTP/1.1 200 OK');
echo('ok');
break;
}
?>
}elseif($getAccount->num_rows == 1 && mb_strtolower($exploded_message) == 'баланс') {
$udata = $getAccount->fetch_array();
return // Вывод баланса
array(str_replace('%1',$udata['money'], str_replace('%2',$udata['gems'],$lang['balance'])),json_encode([
'one_time' => true,
'buttons' => ));
}
///........
'games' => [
'ruletka_none_money' => ' Внимание, у вас не хватает денег на ставку.',
'ruletka_none_stavka' => " Внимание, чтобы сделать ставку введите \"Ставка сумма\"\n Пример: Ставка 5000 (✅ вы сделаете ставку на 5000) ",
'ruletka_format_err' => " Внимание, введите сумму в виде цифр (без лишних символов)\n❗ Например: ставка 1000",
'ruletka_game_result' => " Рулетка (Вы сделали ставку: %1)\n\nРезультат игры: %2 (✅ Вам зачислено %3 )\nВаш баланс теперь: %4 ",
],
Answer the question
In order to leave comments, you need to log in
Unfortunately, this mention in conversations is not removed in any way.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question