diff --git a/modules/ContentStore/Handler/Store.cs b/modules/ContentStore/Handler/Store.cs index df44a2a..d390f43 100644 --- a/modules/ContentStore/Handler/Store.cs +++ b/modules/ContentStore/Handler/Store.cs @@ -7,6 +7,7 @@ using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.Core.Service; using Microsoft.Extensions.DependencyInjection; using Telegram.Bot; +using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; using Telegram.Bot.Types.ReplyMarkups; using West.TelegramBot.ContentStore.Service; @@ -113,13 +114,24 @@ public class Store : BotEventHandler var randomMedia = await mediaService!.GetRandomMediaAsync(); var file = randomMedia.File; + switch (randomMedia.Type) { case InputMediaType.Photo: - await Bot.SendPhotoAsync(Chat.Id, file, 0, randomMedia.Caption, replyToMessageId: messageId, parseMode: ParseMode.Html); + await Bot.SendPhotoAsync(Chat.Id, file, + caption: randomMedia.Caption, + replyToMessageId: messageId, + parseMode: ParseMode.Html, + hasSpoiler: randomMedia.Nsfw + ); break; case InputMediaType.Video: - await Bot.SendVideoAsync(Chat.Id, file, caption: randomMedia.Caption, replyToMessageId: messageId, parseMode: ParseMode.Html); + await Bot.SendVideoAsync(Chat.Id, file, + caption: randomMedia.Caption, + replyToMessageId: messageId, + parseMode: ParseMode.Html, + hasSpoiler: randomMedia.Nsfw + ); break; } } diff --git a/modules/ContentStore/Model/RandomMedia.cs b/modules/ContentStore/Model/RandomMedia.cs index 0791658..a54a884 100644 --- a/modules/ContentStore/Model/RandomMedia.cs +++ b/modules/ContentStore/Model/RandomMedia.cs @@ -5,14 +5,16 @@ namespace West.TelegramBot.ContentStore.Model; public class RandomMedia { - public RandomMedia(IInputFile file, string? caption = null) + public RandomMedia(IInputFile file, string? caption = null, bool nsfw = false) { File = file; Caption = caption; + Nsfw = nsfw; } public IInputFile File; public string? Caption; + public bool Nsfw; public InputMediaType Type { get; set; } = InputMediaType.Photo; } \ No newline at end of file diff --git a/modules/ContentStore/Service/AbstractKittiesService.cs b/modules/ContentStore/Service/AbstractKittiesService.cs index 6c2f43a..6f53ba8 100644 --- a/modules/ContentStore/Service/AbstractKittiesService.cs +++ b/modules/ContentStore/Service/AbstractKittiesService.cs @@ -45,7 +45,8 @@ public abstract class AbstractKittiesService : IRandomMediaService return new RandomMedia( new InputFile(await response.Content.ReadAsStreamAsync()), - new HtmlString().Url(videoSource, videoTitle).ToString() + new HtmlString().Url(videoSource, videoTitle).ToString(), + true ); } diff --git a/modules/ContentStore/Service/AnimBoobsService.cs b/modules/ContentStore/Service/AnimBoobsService.cs index c27ae31..6c50d58 100644 --- a/modules/ContentStore/Service/AnimBoobsService.cs +++ b/modules/ContentStore/Service/AnimBoobsService.cs @@ -24,9 +24,13 @@ public class AnimBoobsService : IRandomMediaService public async Task GetRandomMediaAsync() { var fileName = await _httpClient.GetStringAsync("index.php"); - return new RandomMedia(new InputFileUrl($"https://westdev.me/_boobs/media/{fileName}")) + // https://bugs.telegram.org/c/23674 workaround + var video = await _httpClient.GetStreamAsync($"https://westdev.me/_boobs/media/{fileName}"); + + return new RandomMedia(new InputFile(video, fileName)) { - Type = InputMediaType.Video + Type = InputMediaType.Video, + Nsfw = true }; } diff --git a/modules/ContentStore/Service/OBoobsService.cs b/modules/ContentStore/Service/OBoobsService.cs index f761e1d..40f697f 100644 --- a/modules/ContentStore/Service/OBoobsService.cs +++ b/modules/ContentStore/Service/OBoobsService.cs @@ -29,7 +29,7 @@ public class OBoobsService : IRandomMediaService var boobsItem = boobsResponse![0]; var boobsId = boobsItem.Id.ToString("D5"); - return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model); + return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model, true); } public async Task CanView(Chat chat, User user)