mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
27 lines
687 B
C#
27 lines
687 B
C#
using System.Net.Http;
|
|
using System.Threading.Tasks;
|
|
using Kruzya.TelegramBot.Core.Extensions;
|
|
using Telegram.Bot.Types;
|
|
|
|
namespace Kruzya.TelegramBot.CombotAntiSpam.Combot;
|
|
|
|
public class CombotClient : ICombotClient
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
|
|
public CombotClient(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
public bool IsSpammer(User user)
|
|
{
|
|
return IsSpammerAsync(user).GetAwaiter().GetResult();
|
|
}
|
|
|
|
public async Task<bool> IsSpammerAsync(User user)
|
|
{
|
|
var result = await _httpClient.GetJsonAsync<CombotApiResponse>($"?user_id={user.Id}");
|
|
return result?.IsSpammer ?? false;
|
|
}
|
|
} |