mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
fix: build and lots of obsolete warnings
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<AssemblyName>TelegramBot.CombotAntiSpam</AssemblyName>
|
||||
<RootNamespace>Kruzya.TelegramBot.CombotAntiSpam</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user