From 04a280a74485a4f3840d50162ce4d5d81006432b Mon Sep 17 00:00:00 2001 From: Citrinate Date: Tue, 7 May 2024 12:28:40 -0400 Subject: [PATCH] Crash fix --- BoosterManager/Boosters/BoosterPageResponse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BoosterManager/Boosters/BoosterPageResponse.cs b/BoosterManager/Boosters/BoosterPageResponse.cs index f552fed..f7fc33e 100644 --- a/BoosterManager/Boosters/BoosterPageResponse.cs +++ b/BoosterManager/Boosters/BoosterPageResponse.cs @@ -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; @@ -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));