Update aio get_queue_status method

This commit is contained in:
Andrei 2019-09-04 00:54:10 +03:00
parent 83b6f3bf76
commit e72a96dcf6
1 changed files with 13 additions and 8 deletions

View File

@ -13,6 +13,8 @@ from python3_anticaptcha import (
mods = ("errors", "views", "downloads", "users", "money") mods = ("errors", "views", "downloads", "users", "money")
# available complaint captcha types # available complaint captcha types
complaint_types = ("image", "recaptcha") complaint_types = ("image", "recaptcha")
# availalbe queue ID's
queue_ids = (1, 2, 5, 6, 7, 10)
class AntiCaptchaControl: class AntiCaptchaControl:
@ -49,8 +51,6 @@ class AntiCaptchaControl:
""" """
if mode not in mods: if mode not in mods:
raise ValueError( raise ValueError(
"\nПередан неверный `mode`."
f"\n\tВозможные варинты: {mods}. Вы передали - `{mode}`"
f"\nWrong `mode` parameter. Valid params: {mods}." f"\nWrong `mode` parameter. Valid params: {mods}."
f"\n\tYour param - `{mode}`" f"\n\tYour param - `{mode}`"
) )
@ -71,8 +71,6 @@ class AntiCaptchaControl:
""" """
if captcha_type not in complaint_types: if captcha_type not in complaint_types:
raise ValueError( raise ValueError(
"\nПередан неверный `captcha_type`."
f"\n\tВозможные варинты: {complaint_types}. Вы передали - `{captcha_type}`"
f"\nWrong `captcha_type` parameter. Valid params: {complaint_types}." f"\nWrong `captcha_type` parameter. Valid params: {complaint_types}."
f"\n\tYour param - `{captcha_type}`" f"\n\tYour param - `{captcha_type}`"
) )
@ -111,6 +109,12 @@ class AntiCaptchaControl:
:param queue_id: Номер очереди :param queue_id: Номер очереди
:return: JSON-объект :return: JSON-объект
""" """
if queue_id not in queue_ids:
raise ValueError(
f"\nWrong `mode` parameter. Valid params: {queue_ids}."
f"\n\tYour param - `{queue_id}`"
)
payload = {"queueId": queue_id} payload = {"queueId": queue_id}
answer = requests.post(get_queue_status_url, json=payload) answer = requests.post(get_queue_status_url, json=payload)
@ -152,8 +156,6 @@ class aioAntiCaptchaControl:
""" """
if mode not in mods: if mode not in mods:
raise ValueError( raise ValueError(
"\nПередан неверный `mode`."
f"\n\tВозможные варинты: {mods}. Вы передали - `{mode}`"
f"\nWrong `mode` parameter. Valid params: {mods}." f"\nWrong `mode` parameter. Valid params: {mods}."
f"\n\tYour param - `{mode}`" f"\n\tYour param - `{mode}`"
) )
@ -174,8 +176,6 @@ class aioAntiCaptchaControl:
""" """
if captcha_type not in complaint_types: if captcha_type not in complaint_types:
raise ValueError( raise ValueError(
"\nПередан неверный `captcha_type`."
f"\n\tВозможные варинты: {complaint_types}. Вы передали - `{captcha_type}`"
f"\nWrong `captcha_type` parameter. Valid params: {complaint_types}." f"\nWrong `captcha_type` parameter. Valid params: {complaint_types}."
f"\n\tYour param - `{captcha_type}`" f"\n\tYour param - `{captcha_type}`"
) )
@ -219,6 +219,11 @@ class aioAntiCaptchaControl:
:param queue_id: Номер очереди :param queue_id: Номер очереди
:return: JSON-объект :return: JSON-объект
""" """
if queue_id not in queue_ids:
raise ValueError(
f"\nWrong `mode` parameter. Valid params: {queue_ids}."
f"\n\tYour param - `{queue_id}`"
)
payload = {"queueId": queue_id} payload = {"queueId": queue_id}
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session: