Add delete method to custom.Dialog (#1014)

This commit is contained in:
nailerNAS 2018-09-28 16:47:24 +03:00 committed by Lonami
parent 785071a5cd
commit c2966297f1

View File

@ -1,5 +1,5 @@
from . import Draft
from .. import TLObject, types
from .. import TLObject, types, functions
from ... import utils
@ -96,6 +96,17 @@ class Dialog:
return await self._client.send_message(
self.input_entity, *args, **kwargs)
async def delete(self):
if self.is_channel:
await self._client(functions.channels.LeaveChannelRequest(
self.input_entity))
else:
if self.is_group:
await self._client(functions.messages.DeleteChatUserRequest(
self.entity.id, types.InputPeerSelf()))
await self._client(functions.messages.DeleteHistoryRequest(
self.input_entity, 0))
def to_dict(self):
return {
'_': 'Dialog',