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:
from pyrogram import Client
app = Client("my_client")
async def main():
async with app:
async for dialog in app.get_dialogs():
print(str(dialog.chat.id) + " - " + str(dialog.chat.first_name or str(dialog.chat.title)) )
app.run(main())
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:
from pyrogram import Client
app = Client("Telecom")
async def main():
await app.start()
async for message in app.get_chat_history("1212345678"):
await app.delete_messages("1212345678", message.id)
app.run(main())
--------------------------- 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:
chat_id (int | str) – Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) you can simply use “me” or “self”. For a contact that exists in your Telegram address book you can use his phone number (str).
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!