fix: build and lots of obsolete warnings

This commit is contained in:
Andriy
2025-02-09 17:40:03 +02:00
parent 8917a8ba5f
commit c3a553f68d
29 changed files with 103 additions and 108 deletions
@@ -1,5 +1,5 @@
using System;
using Newtonsoft.Json;
using System.Text.Json.Serialization;
namespace Kruzya.TelegramBot.CombotAntiSpam.Combot;
@@ -7,24 +7,24 @@ internal class CombotApiResponse
{
public class ApiResult
{
[JsonProperty("messages")]
[JsonPropertyName("messages")]
public string[] Messages { get; set; }
[JsonProperty("time_added")]
[JsonPropertyName("time_added")]
public int TimeAdded { get; set; }
[JsonProperty("offenses")]
[JsonPropertyName("offenses")]
public int Offenses { get; set; }
public DateTime AddedAt => DateTimeOffset.FromUnixTimeSeconds(TimeAdded).DateTime;
}
[JsonProperty("ok")]
[JsonPropertyName("ok")]
public bool IsSpammer { get; set; }
[JsonProperty("description")]
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonProperty("result")]
[JsonPropertyName("result")]
public ApiResult Result { get; set; }
}
@@ -22,6 +22,6 @@ public class CombotClient : ICombotClient
public async Task<bool> IsSpammerAsync(User user)
{
var result = await _httpClient.GetJsonAsync<CombotApiResponse>($"?user_id={user.Id}");
return result.IsSpammer;
return result?.IsSpammer ?? false;
}
}