Skip to content

Commit caaeaad

Browse files
committed
Merge branch 'master' into refactor/rnet
2 parents 8c9f3e5 + 21bb713 commit caaeaad

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

discord/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ class CaptchaRequired(HTTPException):
249249
The CAPTCHA service to use. Usually ``hcaptcha``.
250250
251251
.. versionadded:: 2.1
252+
session_id: Optional[:class:`str`]
253+
The CAPTCHA session ID.
252254
rqdata: Optional[:class:`str`]
253255
The enterprise hCaptcha request data.
254256
@@ -267,6 +269,7 @@ class CaptchaRequired(HTTPException):
267269
'errors',
268270
'service',
269271
'_sitekey',
272+
'session_id',
270273
'rqdata',
271274
'rqtoken',
272275
'should_serve_invisible',
@@ -281,6 +284,7 @@ def __init__(self, response: _ResponseType, message: CaptchaPayload):
281284
self.errors: List[str] = message['captcha_key']
282285
self.service: CaptchaService = message.get('captcha_service', 'recaptcha')
283286
self._sitekey: str | None = message.get('captcha_sitekey')
287+
self.session_id: Optional[str] = message.get('captcha_session_id')
284288
self.rqdata: Optional[str] = message.get('captcha_rqdata')
285289
self.rqtoken: Optional[str] = message.get('captcha_rqtoken')
286290
self.should_serve_invisible: bool = message.get('should_serve_invisible', False)

discord/http.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,11 +1014,13 @@ async def request(
10141014
except CaptchaRequired as e:
10151015
# The way captcha handling works is completely transparent
10161016
# The user is expected to provide a handler that will be called to return a solution
1017-
# Then, we just insert the solution + rqtoken (if applicable) into the headers and retry the request
1017+
# Then, we just insert the solution + session into the headers and retry the request
10181018
if captcha_handler is None or tries == 4:
10191019
raise
10201020
else:
10211021
headers['X-Captcha-Key'] = await captcha_handler(e)
1022+
if e.session_id:
1023+
headers['X-Captcha-Session-Id'] = e.session_id
10221024
if e.rqtoken:
10231025
headers['X-Captcha-Rqtoken'] = e.rqtoken
10241026

discord/types/error.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class CaptchaRequired(TypedDict):
5353
captcha_key: List[str]
5454
captcha_service: NotRequired[CaptchaService]
5555
captcha_sitekey: Optional[str]
56+
captcha_session_id: NotRequired[str]
5657
captcha_rqdata: NotRequired[str]
5758
captcha_rqtoken: NotRequired[str]
5859
should_serve_invisible: NotRequired[bool]

0 commit comments

Comments
 (0)