Skip to content

Commit a4630ac

Browse files
committed
Update control.py
1 parent 4ad28b0 commit a4630ac

File tree

1 file changed

+76
-71
lines changed

1 file changed

+76
-71
lines changed

src/python_rucaptcha/control.py

+76-71
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,38 @@ def __init__(
1616
action: Control action type
1717
1818
Examples:
19-
>>> Control(rucaptcha_key="aa9.....",
20-
... action=ControlEnm.getBalance.value).report()
19+
>>> Control(rucaptcha_key="aa9.....").getBalance()
2120
{
22-
'captchaSolve': '1',
23-
'taskId': None,
24-
'error': False,
25-
'errorBody': None
21+
'balance': 1593.4479
22+
}
23+
24+
>>> await Control(rucaptcha_key="aa9.....").aio_getBalance()
25+
{
26+
'balance': 1593.4479
27+
}
28+
29+
>>> Control(rucaptcha_key="aa9.....").reportCorrect(id=75188571838)
30+
{
31+
'errorId': 0,
32+
'status': 'success'
33+
}
34+
35+
>>> await Control(rucaptcha_key="aa9.....").aio_reportCorrect(id=75188571838)
36+
{
37+
'errorId': 0,
38+
'status': 'success'
39+
}
40+
41+
>>> Control(rucaptcha_key="aa9.....").reportIncorrect(id=75188571838)
42+
{
43+
'errorId': 0,
44+
'status': 'success'
45+
}
46+
47+
>>> await Control(rucaptcha_key="aa9.....").aio_reportIncorrect(id=75188571838)
48+
{
49+
'errorId': 0,
50+
'status': 'success'
2651
}
2752
2853
Returns:
@@ -36,104 +61,84 @@ def __init__(
3661

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

39-
def report(self, id: str) -> dict:
64+
def reportCorrect(self, id: int) -> dict:
4065
"""
41-
Captcha results report
66+
reportCorrect method
4267
4368
Args:
4469
id: Captcha task ID
4570
46-
Examples:
47-
>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
48-
... action=ControlEnm.GET.value).report(id="73043727671")
49-
{
50-
'captchaSolve': '1',
51-
'taskId': None,
52-
'error': False,
53-
'errorBody': None
54-
}
71+
Returns:
72+
Dict with full server response
5573
56-
>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
57-
... action=ControlEnm.REPORTGOOD.value).report(id="73043727671")
58-
{
59-
'captchaSolve': 'OK_REPORT_RECORDED',
60-
'taskId': None,
61-
'error': False,
62-
'errorBody': None
63-
}
74+
Notes:
75+
https://2captcha.com/api-docs/report-correct
76+
"""
77+
self.get_task_payload.taskId = id
78+
return get_sync_result(
79+
get_payload=self.get_task_payload,
80+
sleep_time=self.params.sleep_time,
81+
url_response=f"https://api.{self.params.service_type}.com/reportCorrect",
82+
)
6483

65-
>>> Control(rucaptcha_key="aa9011f31111181111168611f1151122",
66-
... action=ControlEnm.REPORTBAD.value).report(id="73043727671")
67-
{
68-
'captchaSolve': 'OK_REPORT_RECORDED',
69-
'taskId': None,
70-
'error': False,
71-
'errorBody': None
72-
}
84+
async def aio_reportCorrect(self, id: int) -> dict:
85+
"""
86+
Captcha results report
7387
88+
Args:
89+
id: Captcha task ID
7490
7591
Returns:
7692
Dict with full server response
7793
7894
Notes:
79-
https://rucaptcha.com/api-rucaptcha#complain
95+
https://2captcha.com/api-docs/report-correct
8096
"""
81-
self.get_payload.update({"id": id})
82-
return get_sync_result(
83-
get_payload=self.get_payload,
97+
self.get_task_payload.taskId = id
98+
return await get_async_result(
99+
get_payload=self.get_task_payload,
84100
sleep_time=self.params.sleep_time,
85-
url_response=self.params.url_response,
86-
result=self.result,
101+
url_response=f"https://api.{self.params.service_type}.com/reportCorrect",
87102
)
88103

89-
async def aio_report(self, id: str) -> dict:
104+
def reportIncorrect(self, id: int) -> dict:
90105
"""
91-
Captcha results report
106+
reportCorrect method
92107
93108
Args:
94109
id: Captcha task ID
95110
96-
Examples:
97-
>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
98-
... action=ControlEnm.GET.value).aio_report(id="73043727671")
99-
{
100-
'captchaSolve': '1',
101-
'taskId': None,
102-
'error': False,
103-
'errorBody': None
104-
}
111+
Returns:
112+
Dict with full server response
105113
106-
>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
107-
... action=ControlEnm.REPORTGOOD.value).aio_report(id="73043727671")
108-
{
109-
'captchaSolve': 'OK_REPORT_RECORDED',
110-
'taskId': None,
111-
'error': False,
112-
'errorBody': None
113-
}
114+
Notes:
115+
https://2captcha.com/api-docs/report-incorrect
116+
"""
117+
self.get_task_payload.taskId = id
118+
return get_sync_result(
119+
get_payload=self.get_task_payload,
120+
sleep_time=self.params.sleep_time,
121+
url_response=f"https://api.{self.params.service_type}.com/reportIncorrect",
122+
)
114123

115-
>>> await Control(rucaptcha_key="aa9011f31111181111168611f1151122",
116-
... action=ControlEnm.REPORTBAD.value).aio_report(id="73043727671")
117-
{
118-
'captchaSolve': 'OK_REPORT_RECORDED',
119-
'taskId': None,
120-
'error': False,
121-
'errorBody': None
122-
}
124+
async def aio_reportIncorrect(self, id: int) -> dict:
125+
"""
126+
Captcha results report
123127
128+
Args:
129+
id: Captcha task ID
124130
125131
Returns:
126132
Dict with full server response
127133
128134
Notes:
129-
https://rucaptcha.com/api-rucaptcha#complain
135+
https://2captcha.com/api-docs/report-incorrect
130136
"""
131-
self.get_payload.update({"id": id})
137+
self.get_task_payload.taskId = id
132138
return await get_async_result(
133-
get_payload=self.get_payload,
139+
get_payload=self.get_task_payload,
134140
sleep_time=self.params.sleep_time,
135-
url_response=self.params.url_response,
136-
result=self.result,
141+
url_response=f"https://api.{self.params.service_type}.com/reportIncorrect",
137142
)
138143

139144
def getBalance(self) -> dict:

0 commit comments

Comments
 (0)