mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-23 01:46:35 +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 getpass
|
||||||
import hashlib
|
import hashlib
|
||||||
import sys
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
from .messageparse import MessageParseMethods
|
from .messageparse import MessageParseMethods
|
||||||
from .users import UserMethods
|
from .users import UserMethods
|
||||||
|
@ -459,3 +458,19 @@ class AuthMethods(MessageParseMethods, UserMethods):
|
||||||
))
|
))
|
||||||
|
|
||||||
# endregion
|
# 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