如何删除私人聊天(pyrogram)
我尝试了 pyrogram.raw.functions.messages.deletechat
,但要获得以下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
也有相同的问题。
await client.invoke(UpdateNotifySettings(peer=await client.resolve_peer(cid),settings=InputPeerNotifySettings(silent=True)))
我读过此 client.archive_chats 与相同的ID效果很好。
ID就像此 5126101582
是否有其他类型的ID或我的代码是错误的
注: 我需要的就是这样:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更新
好吧,我认为我也找到了一个个人聊天的解决方案!
我当时弄乱了其他东西,然后阅读文档的这一部分,我来了以一种列出每个对话及其各自ID的方式:
基本上它的作用是循环循环您的所有聊天,并在组/频道的情况下输出其ID和“标题”,而在与某人进行聊天的情况下,它的名字是一个名字。您会注意到,某些ID将在其前面使用连字符( - )输出,而有些ID则不会。
您需要在有或没有连字符的情况下复制该精确的字符串,然后您可以从聊天中删除所有消息:
------------------------------------------------------------------------------------------------- ----- 更新的结尾 -----------------------------------------------------------------------------------------------------》
是否仅仅要删除特定聊天的消息,或者您想删除聊天本身。
无论如何,这就是文档所说的:
参考:
pyrogram文档 - 删除消息
除非是频道/机器人/组 - 并且由于您收到此错误,我假设您想删除与某人的聊天。
现在,如果您试图删除带有频道的消息,则有几种方法可以检索正确的ID。
我使用的最多的是去Web.Telegram并将其更改为“遗产”版本。
到达那里后,单击您要删除消息的聊天ID。您应该看到这样的东西:
态
您将需要“ C”之后和下划线之前的数字。
因此,假设我的电话是C1503123456789_11111111111
您将使用1503123456789。
您还需要向其添加-100。因此,最终数字将是:
-1001503123456789。
我希望这对某种方式有所帮助。
祝你好运!
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!
您可以使用
well_chat
方法删除对话框。留下聊天或频道
离开基本聊天,还删除对话框
的聊天方法。
用作捷径:
示例
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
精美的
作品
fine
works