Search code examples
pythontelegrampyrogram

How to delete a private chat (pyrogram)


i tried pyrogram.raw.functions.messages.DeleteChat but get following trackback

pyrogram.errors.exceptions.bad_request_400.PeerIdInvalid: Telegram says: [400 PEER_ID_INVALID] - The peer id being used is invalid or not known yet. Make sure you meet the peer before interacting with it (caused by "messages.DeleteChat")

account.UpdateNotifySettings has the same problem too.

await client.invoke(UpdateNotifySettings(peer=await client.resolve_peer(cid),settings=InputPeerNotifySettings(silent=True)))

i have read this doc and i am sure that the id is correct for client.archive_chats works well with the same id.

the id is like this 5126101582 is there any another kinds of id or my code is wrong

note: what i need is like this:

enter image description here


Solution

  • fine

    await client.invoke(DeleteHistory(max_id=0, peer=await client.resolve_peer(cid))
    

    works