dolfies / discord.py-self

A fork of the popular discord.py for user accounts.
https://discordpy-self.rtfd.io/en/latest/
MIT License
688 stars 160 forks source link

Fix fallback build number retrieval #596

Closed ye4241 closed 10 months ago

ye4241 commented 11 months ago

Summary

Fix _get_build_number find error with new string 'Build Number: ").concat("', issue #597

General Info

In latest discord website, the build number finding has been updated.

0xking-sol commented 11 months ago

yep this fixes it for me

omega9t9 commented 11 months ago

This worked for me 😄😄 many thanks mate ♥️

paulofreitas commented 11 months ago

Better fix, but...

build_find = re.match(r'.*Build Number:\D+(\d+).*', build_file)
return int(build_find.group(1)) if build_find else 243588

...would be even better. 👍

ye4241 commented 11 months ago

@paulofreitas I have updated to use regex to find build number and detect all exceptions (maybe).

paulofreitas commented 11 months ago

@paulofreitas I have updated to use regex to find build number and detect all exceptions (maybe).

@ye4241 It's much better now, but do note that the quotes in the regex are not needed, nor the call to str.is_numeric(). The \D+ in the regex will skip anything between the colon : and the first number, and the (\d+) part will only match the numbers up to the next non-number. So the regex alone will do a perfect match and will only return if it does actually match anything - if it doesn't work it means they changed the code again. 👍

ye4241 commented 11 months ago

@paulofreitas Indeed, I have remove the useless detect for number, and add the default build number.

omega9t9 commented 10 months ago

i did some experiments with the solution you provided, it works in single token code (always)

But in multiple token code it gives clientOSexecption error (sometimes)

While a very little times, it works like nothing happened, it works perfectly fine (tested in 8 token code) (rarely works)

help

dolfies commented 10 months ago

Thanks for the PR! I'll merge this now to solve the issue at hand, but I'll rework this fallback code later on and add tests to be a little more resilient. Looks like I've neglected it a little bit after I offloaded things to a separate API.

The API should be back within a week or so. I've been very busy recently and haven't had time to deal with some hosting issues.