Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
800 stars 340 forks source link

How use setChatPermissions? #226

Closed JOSDC01 closed 3 years ago

masihgh commented 3 years ago

Yes ihave problem for use restrictChatMember and setChatPermissions pls help us! don't work this code

**$content = array( "chat_id" => $chat_id, "user_id" => $new_chat_members['id'], "can_post_messages" => FALSE, ); $uid = $new_chat_members['id']; $telegram->restrictChatMember($content);

    sleep(10);

    $content = array(
        "chat_id" => $chat_id,
        "user_id" => u$uid,
        "can_post_messages" => TRUE,
    );
    $telegram->restrictChatMember($content);**
JOSDC01 commented 3 years ago

I already have the solution, but the bot must be admin

$permissions = [ 'can_send_messages' => true, 'can_send_media_messages' => true ];

$chatPermissions = json_encode($permissions, true);

$content = array('chat_id' => $chat_id, 'permissions' => $chatPermissions); $telegram->setChatPermissions($content);

And the file Telegram.php you add this

public function setChatPermissions(array $content) { return $this->endpoint('setChatPermissions', $content); }

masihgh commented 3 years ago

thanks!