ye4241
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
3 deletions
-
discord/utils.py
|
|
@ -1473,17 +1473,18 @@ async def _get_info(session: ClientSession) -> Tuple[Dict[str, Any], str]: |
|
|
|
|
|
|
|
async def _get_build_number(session: ClientSession) -> int: # Thank you Discord-S.C.U.M |
|
|
|
"""Fetches client build number""" |
|
|
|
default_build_number = 9999 |
|
|
|
try: |
|
|
|
login_page_request = await session.get('https://discord.com/login', timeout=7) |
|
|
|
login_page = await login_page_request.text() |
|
|
|
build_url = 'https://discord.com/assets/' + re.compile(r'assets/+([a-z0-9]+)\.js').findall(login_page)[-2] + '.js' |
|
|
|
build_request = await session.get(build_url, timeout=7) |
|
|
|
build_file = await build_request.text() |
|
|
|
build_index = build_file.find('buildNumber') + 24 |
|
|
|
return int(build_file[build_index : build_index + 6]) |
|
|
|
build_find = re.findall(r'Build Number:\D+"(\d+)"', build_file) |
|
|
|
return int(build_find[0]) if build_find else default_build_number |
|
|
|
except asyncio.TimeoutError: |
|
|
|
_log.critical('Could not fetch client build number. Falling back to hardcoded value...') |
|
|
|
return 9999 |
|
|
|
return default_build_number |
|
|
|
|
|
|
|
|
|
|
|
async def _get_user_agent(session: ClientSession) -> str: |
|
|
|