Skip to content
Permalink
Browse files

Let delete_dialog work for bot accounts without erroring

  • Loading branch information...
Lonami committed Sep 10, 2019
1 parent 0bf4c4a commit 5c72e1286ed60d940c1dbfc582e299c93a806f8a
Showing with 10 additions and 1 deletion.
  1. +10 −1 telethon/client/dialogs.py
@@ -401,6 +401,10 @@ def iter_drafts(
"""
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 @@ def iter_drafts(
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 @@ def iter_drafts(
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(

0 comments on commit 5c72e12

Please sign in to comment.
You can’t perform that action at this time.