Files
telegram-bot/modules/ContentStore/Service/OBoobsService.cs
T

29 lines
1.2 KiB
C#

using Newtonsoft.Json;
using Telegram.Bot.Types;
using West.TelegramBot.ContentStore.Model;
using West.TelegramBot.ContentStore.Option;
namespace West.TelegramBot.ContentStore.Service;
public class OBoobsService : AbstractNsfwService
{
private readonly HttpClient _httpClient;
public override StoreItem StoreItem { get; } = new("boobs", "Сиськи", 60, 30);
public OBoobsService(AllowNsfw allowNsfw, IHttpClientFactory factory) : base(allowNsfw)
{
_httpClient = factory.CreateClient();
_httpClient.BaseAddress = new Uri("http://api.oboobs.ru");
}
public override async Task<RandomMedia> GetRandomMediaAsync(Chat chat, User user)
{
// "/boobs/{start=0; sql offset}/{count=1; sql limit}/{order=-id;[id,rank,-rank,interest,-interest,random]}/
var httpResp = await _httpClient.GetAsync("boobs/1/1/random");
var boobsResponse = JsonConvert.DeserializeObject<List<OBoobsItem>>(await httpResp.Content.ReadAsStringAsync());
var boobsItem = boobsResponse![0];
var boobsId = boobsItem.Id.ToString("D5");
return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model, true);
}
}