mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 11:23:46 +03:00
Support using the client in with blocks
This commit is contained in:
parent
d4b508bf48
commit
32786d16fd
|
@ -1,8 +1,7 @@
|
|||
import getpass
|
||||
import hashlib
|
||||
import sys
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .messageparse import MessageParseMethods
|
||||
from .users import UserMethods
|
||||
|
@ -459,3 +458,19 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
|||
))
|
||||
|
||||
# endregion
|
||||
|
||||
# region with blocks
|
||||
|
||||
def __enter__(self):
|
||||
return self.start()
|
||||
|
||||
async def __aenter__(self):
|
||||
return await self.start()
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.disconnect()
|
||||
|
||||
async def __aexit__(self, *args):
|
||||
await self.disconnect()
|
||||
|
||||
# endregion
|
||||
|
|
Loading…
Reference in New Issue
Block a user