B
B
baldeyu2020-06-22 14:19:49
Python
baldeyu, 2020-06-22 14:19:49

Telegram Bot Api does not return the right to send a message?

The chat bot is an administrator and has full rights. After disabling the ability to send messages to users, the bot using the telegram api cannot enable the ability to send messages, a successful result is sent, but nothing happens

url = f'https://api.telegram.org/bot{token}/setChatPermissions?chat_id=-1001386422499'
prm = {
            '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_invite_users' : True
        }
r = requests.post(url, params = prm)
print(r.text)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-22
@SoreMix

It is necessary to use a structure of this kind. chat_id and permissions have strong names and are passed as POST data.
Something like this should work:

prm = {
            '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_invite_users' : True
        }

payload = {
        'chat_id': -1001386422499,
        'permissions': prm
    }

requests.post(url, data=payload)

If it doesn't work - all data should be in a similar form, and chat_id and permissions are POST parameters, permissions may need to be converted to json string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question