[store] Make store use AllowNSFW option

This commit is contained in:
Andriy
2023-07-21 18:40:24 +03:00
parent 613ac5ae22
commit 4893c1240d
11 changed files with 47 additions and 46 deletions
+5 -13
View File
@@ -3,25 +3,24 @@ using Kruzya.TelegramBot.Core.Extensions;
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 : IRandomMediaService
public class OBoobsService : AbstractNsfwService
{
private readonly CoreContext _db;
private readonly HttpClient _httpClient;
public StoreItem StoreItem { get; } = new("boobs", "Сиськи", 60, 30);
public override StoreItem StoreItem { get; } = new("boobs", "Сиськи", 60, 30);
public OBoobsService(CoreContext db)
public OBoobsService(AllowNsfw allowNsfw) : base(allowNsfw)
{
_db = db;
_httpClient = new HttpClient
{
BaseAddress = new Uri("http://api.oboobs.ru")
};
}
public async Task<RandomMedia> GetRandomMediaAsync()
public override async Task<RandomMedia> GetRandomMediaAsync()
{
// "/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");
@@ -31,11 +30,4 @@ public class OBoobsService : IRandomMediaService
return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model, true);
}
public async Task<bool> CanView(Chat chat, User user)
{
var option = await _db.UserValues.FindOrCreateOption(chat.Id, "AllowNSFW");
return option.GetValue(false);
}
}