Search code examples
pythonpyrogram

Transfer Telegram channel ownership using pyrogram library


How to transfer channel ownership?

I want to transfer ownership of a Telegram channel using pyrogram.

There is a promote_chat_member method but it does not have an owner input parameter. There is also a pyrogram.raw.functions.channels.EditCreator method but I don't understand how to use it.


Solution

  • Only working method:

    from pyrogram.utils import compute_password_check
    from pyrogram.raw.functions.account import GetPassword
    from pyrogram.raw.functions.channels import EditCreator
    
    await app.invoke(EditCreator(channel=await app.resolve_peer("channel_username"), user_id=await app.resolve_peer("new_owner_username"), password=compute_password_check(await app.invoke(GetPassword()), password="password_here")))