Support using the client in with blocks

This commit is contained in:
Lonami Exo 2018-06-26 11:26:01 +02:00
parent d4b508bf48
commit 32786d16fd

View File

@ -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