Add contextmanager to Control module

This commit is contained in:
Andrei 2019-02-14 13:33:16 +03:00
parent 5e94e6f453
commit fb9f0e27aa
1 changed files with 17 additions and 1 deletions

View File

@ -11,6 +11,14 @@ class AntiCaptchaControl:
:param anticaptcha_key: Ключ антикапчи
"""
self.ANTICAPTCHA_KEY = anticaptcha_key
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
if exc_type:
return False
return True
def get_balance(self):
'''
@ -43,6 +51,14 @@ class aioAntiCaptchaControl:
:param anticaptcha_key: Ключ антикапчи
"""
self.ANTICAPTCHA_KEY = anticaptcha_key
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, traceback):
if exc_type:
return False
return True
async def get_balance(self):
'''
@ -64,4 +80,4 @@ class aioAntiCaptchaControl:
}
async with aiohttp.ClientSession() as session:
async with session.post(incorrect_captcha_url, json=payload) as resp:
return await resp.json()
return await resp.json()