Pyrogram how to log out of a private channel by id?

94 views Asked by At

For example, i wrote a simple echo-bot, but is not working.

from pyrogram import Client, filters, enums
from pyrogram.raw import functions, types

app = Client(username, api_id, api_hash)

@app.on_message(filters.text)
async def echo(client, message):
    if message.text == "test":
        try:
            await app.leave_chat(-100*******547,delete=True)
        except Exception as e:
            print(e)
app.run()

My code failed and return this trace:

Telegram says: [406 CHANNEL_PRIVATE] - The channel/supergroup is not accessible (caused by "channels.LeaveChannel")

Can you tell me what is wrong in my code?

0

There are 0 answers