From 5c72e1286ed60d940c1dbfc582e299c93a806f8a Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Tue, 10 Sep 2019 21:38:07 +0200 Subject: [PATCH] Let delete_dialog work for bot accounts without erroring --- telethon/client/dialogs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/telethon/client/dialogs.py b/telethon/client/dialogs.py index 24436dfe..25bec5dd 100644 --- a/telethon/client/dialogs.py +++ b/telethon/client/dialogs.py @@ -401,6 +401,10 @@ class DialogMethods: """ Deletes a dialog (leaves a chat or channel). + This method can be used as a user and as a bot. However, + bots will only be able to use it to leave groups and channels + (trying to delete a private conversation will do nothing). + See also `Dialog.delete() `. Arguments @@ -414,6 +418,9 @@ class DialogMethods: the other peer too. By default, it's `False`. Set it to `True` to delete the history for both. + This makes no difference for bot accounts, who can + only leave groups and channels. + Returns The :tl:`Updates` object that the request produces, or nothing for private conversations. @@ -438,7 +445,9 @@ class DialogMethods: else: result = None - await self(functions.messages.DeleteHistoryRequest(entity, 0, revoke=revoke)) + if not await self.is_bot(): + await self(functions.messages.DeleteHistoryRequest(entity, 0, revoke=revoke)) + return result def conversation(