mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
30 lines
813 B
C#
30 lines
813 B
C#
using System;
|
|
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
|
|
{
|
|
public HttpClient _HttpClient;
|
|
|
|
public CombotClient()
|
|
{
|
|
_HttpClient = new HttpClient();
|
|
_HttpClient.BaseAddress = new Uri("https://api.cas.chat/check");
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |