Let delete_dialog work for bot accounts without erroring

This commit is contained in:
Lonami Exo 2019-09-10 21:38:07 +02:00
parent 0bf4c4ae75
commit 5c72e1286e

View File

@ -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() <telethon.tl.custom.dialog.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(