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

29 lines
1.2 KiB
C#
Raw Normal View History

2025-02-09 17:40:03 +02:00
using System.Text.Json;
2022-11-14 00:49:56 +02:00
using Telegram.Bot.Types;
2022-02-16 17:07:30 +02:00
using West.TelegramBot.ContentStore.Model;
2023-07-21 18:40:24 +03:00
using West.TelegramBot.ContentStore.Option;
2022-02-16 17:07:30 +02:00
namespace West.TelegramBot.ContentStore.Service;
2023-07-21 18:40:24 +03:00
public class OBoobsService : AbstractNsfwService
2022-02-16 17:07:30 +02:00
{
private readonly HttpClient _httpClient;
2023-07-21 18:40:24 +03:00
public override StoreItem StoreItem { get; } = new("boobs", "Сиськи", 60, 30);
2022-02-16 18:08:02 +02:00
2023-07-28 23:14:36 +03:00
public OBoobsService(AllowNsfw allowNsfw, IHttpClientFactory factory) : base(allowNsfw)
2022-02-16 17:07:30 +02:00
{
2023-07-28 23:14:36 +03:00
_httpClient = factory.CreateClient();
_httpClient.BaseAddress = new Uri("http://api.oboobs.ru");
2022-02-16 17:07:30 +02:00
}
public override async Task<RandomMedia> GetRandomMediaAsync(Chat chat, User user)
2022-02-16 17:07:30 +02:00
{
// "/boobs/{start=0; sql offset}/{count=1; sql limit}/{order=-id;[id,rank,-rank,interest,-interest,random]}/
2022-02-16 17:07:30 +02:00
var httpResp = await _httpClient.GetAsync("boobs/1/1/random");
2025-02-09 17:40:03 +02:00
var boobsResponse = JsonSerializer.Deserialize<List<OBoobsItem>>(await httpResp.Content.ReadAsStringAsync());
2023-01-02 19:01:03 +02:00
var boobsItem = boobsResponse![0];
2022-02-16 17:07:30 +02:00
var boobsId = boobsItem.Id.ToString("D5");
2023-01-02 23:31:05 +02:00
return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model, true);
2022-02-16 17:07:30 +02:00
}
}