mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-05-02 04:22:04 -04:00
GetChallenge now returns null if no challenge data was found instead of throwing an exception
This commit is contained in:
@@ -29,7 +29,7 @@ public class KiwiFlare(string kfDomain, string? proxy = null, CancellationToken?
|
|||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<KiwiFlareChallengeModel> GetChallenge()
|
public async Task<KiwiFlareChallengeModel?> GetChallenge()
|
||||||
{
|
{
|
||||||
using var client = new HttpClient(GetHttpClientHandler());
|
using var client = new HttpClient(GetHttpClientHandler());
|
||||||
var response = await client.GetAsync($"https://{kfDomain}/", _ctx);
|
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\"]");
|
var challengeData = document.DocumentNode.SelectSingleNode("//html[@id=\"sssg\"]");
|
||||||
if (challengeData == null)
|
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");
|
if (!challengeData.Attributes.Contains("data-sssg-challenge")) throw new Exception("data-sssg-challenge attribute missing");
|
||||||
|
|||||||
Reference in New Issue
Block a user