Answer the question
In order to leave comments, you need to log in
Why does inline bot in telegram not work with different users?
The bot works in online mode, sends messages in groups to a specific user.
To view the message, you need to click on the button, where in advance, even when sending, the unique id and username of the specified person in the group is recorded in the callback_data
$secret_button = [
]
$data = json_decode(file_get_contents('php://input'));
$username = $data->callback_query->from;->username;
$callback_data = $data->callback_query->data;
function message_get($username, $callback_data)
{
global $pdo;
$sql = "SELECT message, receiver_id, username, id
FROM secret_messages
WHERE receiver_id = :username
AND id = :callback_data";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':username', $username, PDO::PARAM_STR);
$stmt->bindParam(':callback_data', $callback_data, PDO::PARAM_STR);
$stmt->execute();
return $stmt->fetch();
}
$receiver_username = explode('-', $callback_data);
$messageData = message_get($username, $receiver_username[1]); // Получение запроса из бд
if ($messageData['receiver_id'] == $receiver_username[0]) { // Если username получателя совпал с тем, что был в запросе
$alert_message = [
'callback_query_id' => $callback_query_id,
'text' => $messageData['message'],
'show_alert' => TRUE
];
sendRequest('answerCallbackQuery', $alert_message);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question