[英]Telethon: Leave a chat not a channel request
I am using the Telethon
Telegram client library.我正在使用
Telethon
Telegram 客户端库。 I need to leave a Chat
but there is only one request for leaving and that is LeaveChannelRequest
.我需要离开
Chat
但只有一个离开请求,那就是LeaveChannelRequest
。
But as the name says, It is for Channels
and not Chats
.但顾名思义,它适用于
Channels
而不是Chats
。
Channels
have both chat_id
and access_hash
but Chats
only have chat_id
. Channels
有chat_id
和access_hash
但Chats
只有chat_id
。
How can I leave a Chat
?我怎样才能离开
Chat
?
I have checked the tdlib
library and it has a thing called CloseChat
which seems to suit what I need, How can I use it here in telethon
?我检查了
tdlib
库,它有一个东西叫CloseChat
这似乎符合我需要什么,我如何在这里使用它telethon
? https://javadoc.tlgrm.ru/org/drinkless/td/libcore/telegram/TdApi.CloseChat.html https://javadoc.tlgrm.ru/org/drinkless/td/libcore/telegram/TdApi.CloseChat.html
You need to kick yourself with DeleteChatUserRequest
:你需要用
DeleteChatUserRequest
踢自己:
client(functions.messages.DeleteChatUserRequest(
chat_id=chat_id,
user_id='me'
))
You can also use dialog.delete()
:您还可以使用
dialog.delete()
:
for dialog in client.iter_dialogs():
if dialog.id == chat_id:
dialog.delete()
On more recent versions, the above can be improved by using client.delete_dialog
instead:在更新的版本中,可以通过使用
client.delete_dialog
来改进上述内容:
client.delete_dialog(chat_id)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.