From 7889f504867de75c15e7047ba74476782928dc43 Mon Sep 17 00:00:00 2001 From: barelyprofessional <150058423+barelyprofessional@users.noreply.github.com> Date: Tue, 19 Aug 2025 21:47:05 -0500 Subject: [PATCH] GetChallenge now returns null if no challenge data was found instead of throwing an exception --- KfChatDotNetBot/Services/KiwiFlare.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/KfChatDotNetBot/Services/KiwiFlare.cs b/KfChatDotNetBot/Services/KiwiFlare.cs index 5d62a30..9ae8457 100644 --- a/KfChatDotNetBot/Services/KiwiFlare.cs +++ b/KfChatDotNetBot/Services/KiwiFlare.cs @@ -29,7 +29,7 @@ public class KiwiFlare(string kfDomain, string? proxy = null, CancellationToken? return handler; } - public async Task GetChallenge() + public async Task GetChallenge() { using var client = new HttpClient(GetHttpClientHandler()); var response = await client.GetAsync($"https://{kfDomain}/", _ctx); @@ -38,7 +38,8 @@ public class KiwiFlare(string kfDomain, string? proxy = null, CancellationToken? var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]"); if (challengeData == null) { - throw new Exception("challengeData was null. Couldn't find html element with id = sssg"); + _logger.Info("challengeData was null. Couldn't find html element with id = sssg, returning null"); + return null; } if (!challengeData.Attributes.Contains("data-sssg-challenge")) throw new Exception("data-sssg-challenge attribute missing");