Skip to content

Commit

Permalink
Crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed May 7, 2024
1 parent e2073f8 commit 04a280a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions BoosterManager/Boosters/BoosterPageResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ internal sealed class BoosterPageResponse {
internal readonly uint GooAmount;
internal readonly uint TradableGooAmount;
internal readonly uint UntradableGooAmount;
private readonly static Regex GooAmounts = new Regex("(?<=parseFloat\\( \")[0-9]+", RegexOptions.CultureInvariant);
private readonly static Regex Info = new Regex("\\[\\{\"[\\s\\S]*\"}]", RegexOptions.CultureInvariant);

internal BoosterPageResponse(Bot bot, IDocument? boosterPage) {
Bot = bot;
Expand All @@ -22,8 +24,8 @@ internal BoosterPageResponse(Bot bot, IDocument? boosterPage) {
throw new Exception();
}

MatchCollection gooAmounts = Regex.Matches(boosterPage.Source.Text, "(?<=parseFloat\\( \")[0-9]+");
Match info = Regex.Match(boosterPage.Source.Text, "\\[\\{\"[\\s\\S]*\"}]");
MatchCollection gooAmounts = GooAmounts.Matches(boosterPage.Source.Text);
Match info = Info.Match(boosterPage.Source.Text);

if (!info.Success || (gooAmounts.Count != 3)) {
Bot.ArchiLogger.LogGenericError(string.Format(ArchiSteamFarm.Localization.Strings.ErrorParsingObject, boosterPage));
Expand Down

0 comments on commit 04a280a

Please sign in to comment.