mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
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<RandomMedia> 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<bool> CanView(Chat chat, User user)
|
|
{
|
|
return await _allowNsfw.GetValueAsync(chat.Id);
|
|
}
|
|
} |