Skip to content

Commit

Permalink
Update control.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDrang committed Dec 6, 2023
1 parent 4ad28b0 commit a4630ac
Showing 1 changed file with 76 additions and 71 deletions.
147 changes: 76 additions & 71 deletions src/python_rucaptcha/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,38 @@ def __init__(
action: Control action type
Examples:
>>> Control(rucaptcha_key="aa9.....",
... action=ControlEnm.getBalance.value).report()
>>> Control(rucaptcha_key="aa9.....").getBalance()
{
'captchaSolve': '1',
'taskId': None,
'error': False,
'errorBody': None
'balance': 1593.4479
}
>>> await Control(rucaptcha_key="aa9.....").aio_getBalance()
{
'balance': 1593.4479
}
>>> Control(rucaptcha_key="aa9.....").reportCorrect(id=75188571838)
{
'errorId': 0,
'status': 'success'
}
>>> await Control(rucaptcha_key="aa9.....").aio_reportCorrect(id=75188571838)
{
'errorId': 0,
'status': 'success'
}
>>> Control(rucaptcha_key="aa9.....").reportIncorrect(id=75188571838)
{
'errorId': 0,
'status': 'success'
}
>>> await Control(rucaptcha_key="aa9.....").aio_reportIncorrect(id=75188571838)
{
'errorId': 0,
'status': 'success'
}
Returns:
Expand All @@ -36,104 +61,84 @@ def __init__(

super().__init__(method=ControlEnm.control, *args, **kwargs)

def report(self, id: str) -> dict:
def reportCorrect(self, id: int) -> dict:
"""
Captcha results report
reportCorrect method
Args:
id: Captcha task ID
Examples:
>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.GET.value).report(id="73043727671")
{
'captchaSolve': '1',
'taskId': None,
'error': False,
'errorBody': None
}
Returns:
Dict with full server response
>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.REPORTGOOD.value).report(id="73043727671")
{
'captchaSolve': 'OK_REPORT_RECORDED',
'taskId': None,
'error': False,
'errorBody': None
}
Notes:
https://2captcha.com/api-docs/report-correct
"""
self.get_task_payload.taskId = id
return get_sync_result(
get_payload=self.get_task_payload,
sleep_time=self.params.sleep_time,
url_response=f"https://api.{self.params.service_type}.com/reportCorrect",
)

>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.REPORTBAD.value).report(id="73043727671")
{
'captchaSolve': 'OK_REPORT_RECORDED',
'taskId': None,
'error': False,
'errorBody': None
}
async def aio_reportCorrect(self, id: int) -> dict:
"""
Captcha results report
Args:
id: Captcha task ID
Returns:
Dict with full server response
Notes:
https://rucaptcha.com/api-rucaptcha#complain
https://2captcha.com/api-docs/report-correct
"""
self.get_payload.update({"id": id})
return get_sync_result(
get_payload=self.get_payload,
self.get_task_payload.taskId = id
return await get_async_result(
get_payload=self.get_task_payload,
sleep_time=self.params.sleep_time,
url_response=self.params.url_response,
result=self.result,
url_response=f"https://api.{self.params.service_type}.com/reportCorrect",
)

async def aio_report(self, id: str) -> dict:
def reportIncorrect(self, id: int) -> dict:
"""
Captcha results report
reportCorrect method
Args:
id: Captcha task ID
Examples:
>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.GET.value).aio_report(id="73043727671")
{
'captchaSolve': '1',
'taskId': None,
'error': False,
'errorBody': None
}
Returns:
Dict with full server response
>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.REPORTGOOD.value).aio_report(id="73043727671")
{
'captchaSolve': 'OK_REPORT_RECORDED',
'taskId': None,
'error': False,
'errorBody': None
}
Notes:
https://2captcha.com/api-docs/report-incorrect
"""
self.get_task_payload.taskId = id
return get_sync_result(
get_payload=self.get_task_payload,
sleep_time=self.params.sleep_time,
url_response=f"https://api.{self.params.service_type}.com/reportIncorrect",
)

>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
... action=ControlEnm.REPORTBAD.value).aio_report(id="73043727671")
{
'captchaSolve': 'OK_REPORT_RECORDED',
'taskId': None,
'error': False,
'errorBody': None
}
async def aio_reportIncorrect(self, id: int) -> dict:
"""
Captcha results report
Args:
id: Captcha task ID
Returns:
Dict with full server response
Notes:
https://rucaptcha.com/api-rucaptcha#complain
https://2captcha.com/api-docs/report-incorrect
"""
self.get_payload.update({"id": id})
self.get_task_payload.taskId = id
return await get_async_result(
get_payload=self.get_payload,
get_payload=self.get_task_payload,
sleep_time=self.params.sleep_time,
url_response=self.params.url_response,
result=self.result,
url_response=f"https://api.{self.params.service_type}.com/reportIncorrect",
)

def getBalance(self) -> dict:
Expand Down

0 comments on commit a4630ac

Please sign in to comment.