Files
telegram-bot/modules/CombotAntiSpam/Combot/CombotClient.cs
T

27 lines
677 B
C#
Raw Normal View History

2023-07-28 19:41:21 +03:00
using System.Net.Http;
2020-03-01 22:46:37 +04:00
using System.Threading.Tasks;
using Kruzya.TelegramBot.Core.Extensions;
using Telegram.Bot.Types;
2023-07-28 19:34:28 +03:00
namespace Kruzya.TelegramBot.CombotAntiSpam.Combot;
public class CombotClient : ICombotClient
2020-03-01 22:46:37 +04:00
{
2023-07-28 19:41:21 +03:00
private readonly HttpClient _httpClient;
2020-03-01 22:46:37 +04:00
2023-07-28 19:41:21 +03:00
public CombotClient(HttpClient httpClient)
2023-07-28 19:34:28 +03:00
{
2023-07-28 19:41:21 +03:00
_httpClient = httpClient;
2023-07-28 19:34:28 +03:00
}
2020-03-01 22:46:37 +04:00
2023-07-28 19:34:28 +03:00
public bool IsSpammer(User user)
{
return IsSpammerAsync(user).GetAwaiter().GetResult();
}
2020-03-01 22:46:37 +04:00
2023-07-28 19:34:28 +03:00
public async Task<bool> IsSpammerAsync(User user)
{
2023-07-28 19:41:21 +03:00
var result = await _httpClient.GetJsonAsync<CombotApiResponse>($"?user_id={user.Id}");
2023-07-28 19:34:28 +03:00
return result.IsSpammer;
2020-03-01 22:46:37 +04:00
}
}