skip to Main Content

I tried to set chat permission for the pilot version of my bot using this url:

https://api.telegram.org/bot<token>/setChatPermissions?chat_id=<chat_id>&can_send_messages=0

But I must try it almost 20 times until it really works and the 19 other times, nothing happens.
Wondering I always receive this back even when it does not anything:

{"ok":true,"result":true}

What is the problem? Is it a telegram side problem or it’s from my url?

2

Answers


  1. I think you need to do this as a POST request (or serialize the parameter value in GET request). Analyzing the source code of the random tool, I found another method containing parameters of complex types, and it looked like this:

    api.sendMessage({
      chat_id: <YOUR CHAT ID>,
      text: 'Click on buttons below',
      reply_markup: JSON.stringify({ /* Object with config */ })
    })
    

    This, and the syntax described in the documentation, suggests that the permissions field must be given:

    api.setChatPermissions({
      chat_id: <YOUR CHAT ID>,
      permissions: JSON.stringify({
        can_send_messages: false
      })
    })
    

    I found the sample code in this repository: telegram-bot-api

    Login or Signup to reply.
  2. It is not correct to send it as you send.
    Please send the permissions as json:

    https://api.telegram.org/bot/setChatPermissions?chat_id=<chat_id>&permissions={"can_send_messages":true}

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search