pyrogram / pyrogram

Elegant, modern and asynchronous Telegram MTProto API framework in Python for users and bots
https://pyrogram.org
GNU Lesser General Public License v3.0
4.23k stars 1.37k forks source link

There is no way to add a bot to a channel #1206

Open blacknoize404 opened 1 year ago

blacknoize404 commented 1 year ago

Checklist

Description

Using pyrogram as user client:

The promote_chat_member method does not work to assign privileges to a bot you want to add to a channel.

Then using the add_chat_members method throws a 400 error because the bot needs admin permissions to be added to the channel.

I haven't found any kind of way to make this possible.

Steps to reproduce

Create an script and try to promote the bot in the channel Then add the bot Throws error 400...

Code example

await app.promote_chat_member("test_channel", "@test_bot")
await app.add_chat_members("test_channel", ["@test_bot"])
Throws error 400...

Logs

No response

moshe-coh commented 1 year ago

This is your error, you must add ChatPrivileges

code example:

  await client.promote_chat_member(
      chat,
      admin,
      ChatPrivileges(
          can_invite_users=True,
          can_promote_members=True,
          can_manage_chat=True,
          can_manage_video_chats=True,
          can_change_info=True,
          can_delete_messages=True,
          can_pin_messages=True,
          can_restrict_members=True,
          can_post_messages=True,
          can_edit_messages=True
      )
  )

Such questions should be asked at https://t.me/pyrogramchat or simply read the documents...