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:
3
Answers
fine
works
UPDATE
Ok, I THINK I’ve found a solution for personal chats too!
I was messing around with something else and reading this part of the documentation, I have come up with a way of listing every conversation and their respective id:
Basically what it does is loop through all your chats and output their id and "title" in case of a group/channel and a name in case of a chat with a person. You will notice that some ids will be output with a hyphen (-) in front of them, and some won’t.
You will need to copy that exact string with or without the hyphen and then you can do this to delete all messages from a chat:
————————— END OF UPDATE ————————
I could not understand clearly if you want to delete only the messages of a specific chat or if you want to delete the chat per se.
Anyways, here’s what the documentation says:
Reference:
Pyrogram Documentation – Delete Messages
Therefore, you cannot delete messages from a chat with the ID, unless it’s a channel/bot/group – and since you’re receiving this error, I’m assuming you want to delete a chat with a person.
Now, if you are trying to delete, let’s say, messages with a channel, there are several ways to retrieve the right ID.
The one I use the most is going to web.telegram and changing it to the "legacy" version.
Once there, click on the chat id you want to delete messages with. You should see something like this:
Telegram URL
you will need the numbers after the "c", and before the underscore.
So let’s say my number is c1503123456789_1111111111111
You will use 1503123456789.
You also need to add -100 to it. So the final number will be:
-1001503123456789.
I hope that helps somehow.
Good luck!
you can delete a dialog with
leave_chat
method.Leave chat or channel
Leave basic chat and also delete the dialog
Bound method leave of Chat.
Use as a shortcut for:
Example