mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-27 17:54:38 +03:00
Add delete method to custom.Dialog (#1014)
This commit is contained in:
parent
785071a5cd
commit
c2966297f1
|
@ -1,5 +1,5 @@
|
||||||
from . import Draft
|
from . import Draft
|
||||||
from .. import TLObject, types
|
from .. import TLObject, types, functions
|
||||||
from ... import utils
|
from ... import utils
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,6 +96,17 @@ class Dialog:
|
||||||
return await self._client.send_message(
|
return await self._client.send_message(
|
||||||
self.input_entity, *args, **kwargs)
|
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):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
'_': 'Dialog',
|
'_': 'Dialog',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user