mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 21:24:35 +03:00
Add Conversation to the sync magic module
This commit is contained in:
parent
48113851a8
commit
cc067b2569
|
@ -18,7 +18,7 @@ from async_generator import isasyncgenfunction
|
||||||
|
|
||||||
from .client.telegramclient import TelegramClient
|
from .client.telegramclient import TelegramClient
|
||||||
from .tl.custom import (
|
from .tl.custom import (
|
||||||
Draft, Dialog, MessageButton, Forward, Message, InlineResult
|
Draft, Dialog, MessageButton, Forward, Message, InlineResult, Conversation
|
||||||
)
|
)
|
||||||
from .tl.custom.chatgetter import ChatGetter
|
from .tl.custom.chatgetter import ChatGetter
|
||||||
from .tl.custom.sendergetter import SenderGetter
|
from .tl.custom.sendergetter import SenderGetter
|
||||||
|
@ -83,4 +83,4 @@ def syncify(*types):
|
||||||
|
|
||||||
|
|
||||||
syncify(TelegramClient, Draft, Dialog, MessageButton,
|
syncify(TelegramClient, Draft, Dialog, MessageButton,
|
||||||
ChatGetter, SenderGetter, Forward, Message, InlineResult)
|
ChatGetter, SenderGetter, Forward, Message, InlineResult, Conversation)
|
||||||
|
|
|
@ -420,6 +420,9 @@ class Conversation(ChatGetter):
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self._client.loop.run_until_complete(self.__aenter__())
|
||||||
|
|
||||||
async def __aenter__(self):
|
async def __aenter__(self):
|
||||||
self._client._conversations[self._id] = self
|
self._client._conversations[self._id] = self
|
||||||
self._input_chat = \
|
self._input_chat = \
|
||||||
|
@ -439,5 +442,8 @@ class Conversation(ChatGetter):
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
return self._client.loop.run_until_complete(self.__aexit__(*args))
|
||||||
|
|
||||||
async def __aexit__(self, *args):
|
async def __aexit__(self, *args):
|
||||||
del self._client._conversations[self._id]
|
del self._client._conversations[self._id]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user