Added more logging and error checking for DLive as it's a piece of shit

This commit is contained in:
barelyprofessional
2025-10-25 17:44:32 -05:00
parent 7a625f218f
commit ee40d14fa6

View File

@@ -150,13 +150,22 @@ public class DLive(ChatBot kfChatBot) : IDisposable
// } // }
// } // }
// } // }
try
{
var responseData = content.GetProperty("data").GetProperty("userByDisplayName"); var responseData = content.GetProperty("data").GetProperty("userByDisplayName");
if (responseData.ValueKind == JsonValueKind.Null)
{
logger.Error($"userByDisplayName was null for {username}. Just going to throw an exception because who knows what's going on");
logger.Error(content.GetRawText);
throw new NullReferenceException($"userByDisplayName for {username}");
}
var isLive = responseData.GetProperty("livestream").ValueKind == JsonValueKind.Object; var isLive = responseData.GetProperty("livestream").ValueKind == JsonValueKind.Object;
string? title = null; string? title = null;
if (isLive) if (isLive)
{ {
title = responseData.GetProperty("livestream").GetProperty("title").GetString(); title = responseData.GetProperty("livestream").GetProperty("title").GetString();
} }
return new DLiveIsLiveModel return new DLiveIsLiveModel
{ {
IsLive = isLive, IsLive = isLive,
@@ -164,6 +173,13 @@ public class DLive(ChatBot kfChatBot) : IDisposable
Username = responseData.GetProperty("username").GetString() ?? "username was null in GraphQL response" Username = responseData.GetProperty("username").GetString() ?? "username was null in GraphQL response"
}; };
} }
catch (Exception e)
{
logger.Error($"Bot shit itself while trying to check if {username} is live. JSON payload follows");
logger.Error(content.GetRawText);
throw;
}
}
public void Dispose() public void Dispose()
{ {