Answer the question
In order to leave comments, you need to log in
How to solve api telegram problem with blocking users?
Hello, I wrote a bot that should block absolutely all new chat users (excluding those whose username is in the database)
Here is my code:
$data = json_decode(file_get_contents('php://input'));
if (isset($data->{'message'}->{'chat'}->{'type'}) && $data->{'message'}->{'chat'}->{'type'} == 'supergroup')
{
$id_user = $data->{'message'}->{'new_chat_members'}->{'id'};
$id_chat = $data->{'message'}->{'chat'}->{'id'};
$username_chat = $data->{'message'}->{'chat'}->{'username'};
$username_user = $data->{'message'}->{'new_chat_members'}->{'username'};
$query_count = mysqli_query($connect, "SELECT * FROM `telegram` WHERE `chat_username` = '".$username_chat."' AND `username` = '".$username_user."'");
$query_count = mysqli_num_rows($query_count);
if (!($query_count))
file_get_contents("https://api.telegram.org/botHASH/restrictChatMember?chat_id=".$id_chat."&user_id=".$id_user);
}
Answer the question
In order to leave comments, you need to log in
permissions needs to be sent
'can_send_messages' => true,
'can_send_media_messages' => true,
'can_send_polls' => true,
'can_send_other_messages' => true,
'can_add_web_page_previews' => true,
'can_change_info' => true,
'can_invite_users' => true,
'can_pin_messages' => true,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question