using BotFramework.Utils; using Telegram.Bot.Types; using West.TelegramBot.ContentStore.API; using West.TelegramBot.ContentStore.Model; using West.TelegramBot.ContentStore.Option; namespace West.TelegramBot.ContentStore.Service.Kitties; public abstract class AbstractKittiesService : IRandomMediaService { private readonly IKittiesApi _api; private readonly AllowNsfw _allowNsfw; protected abstract string VideoType { get; } public abstract StoreItem StoreItem { get; } protected AbstractKittiesService(IKittiesApi api, AllowNsfw allowNsfw) { _api = api; _allowNsfw = allowNsfw; } public async Task GetRandomMediaAsync() { var response = await _api.GetKittiesImageAsync(VideoType); return new RandomMedia( new InputFile(response.Content), new HtmlString().Url(response.Source, response.Title).ToString(), true ); } public async Task CanView(Chat chat, User user) { return await _allowNsfw.GetValueAsync(chat.Id); } }