From 20e5bbac8996926692efe22221c23668ec400f59 Mon Sep 17 00:00:00 2001 From: Toastie Date: Mon, 29 Jul 2024 18:32:34 +1200 Subject: [PATCH] Removed .rip command --- src/EllieBot/Modules/Searches/Searches.cs | 10 --- .../Modules/Searches/SearchesService.cs | 63 ++----------------- src/EllieBot/Services/Impl/ImageCache.cs | 6 -- src/EllieBot/_common/ImageUrls.cs | 10 +-- .../_common/Services/Impl/FontProvider.cs | 6 -- .../_common/Services/Impl/IImageCache.cs | 2 - src/EllieBot/data/aliases.yml | 2 - .../data/strings/commands/commands.en-US.yml | 7 --- 8 files changed, 7 insertions(+), 99 deletions(-) diff --git a/src/EllieBot/Modules/Searches/Searches.cs b/src/EllieBot/Modules/Searches/Searches.cs index 6de2b01..b9e189b 100644 --- a/src/EllieBot/Modules/Searches/Searches.cs +++ b/src/EllieBot/Modules/Searches/Searches.cs @@ -39,16 +39,6 @@ public partial class Searches : EllieModule _tzSvc = tzSvc; } - [Cmd] - public async Task Rip([Leftover] IGuildUser usr) - { - var av = usr.RealAvatarUrl(); - await using var picStream = await _service.GetRipPictureAsync(usr.Nickname ?? usr.Username, av); - await ctx.Channel.SendFileAsync(picStream, - "rip.png", - $"Rip {Format.Bold(usr.ToString())} \n\t- " + Format.Italics(ctx.User.ToString())); - } - [Cmd] public async Task Weather([Leftover] string query) { diff --git a/src/EllieBot/Modules/Searches/SearchesService.cs b/src/EllieBot/Modules/Searches/SearchesService.cs index 742f71c..4cdd5e8 100644 --- a/src/EllieBot/Modules/Searches/SearchesService.cs +++ b/src/EllieBot/Modules/Searches/SearchesService.cs @@ -73,56 +73,6 @@ public class SearchesService : IEService } } - public async Task GetRipPictureAsync(string text, Uri imgUrl) - => (await GetRipPictureFactory(text, imgUrl)).ToStream(); - - private void DrawAvatar(Image bg, Image avatarImage) - => bg.Mutate(x => x.Grayscale().DrawImage(avatarImage, new(83, 139), new GraphicsOptions())); - - public async Task GetRipPictureFactory(string text, Uri avatarUrl) - { - using var bg = Image.Load(await _imgs.GetRipBgAsync()); - var result = await _c.GetImageDataAsync(avatarUrl); - if (!result.TryPickT0(out var data, out _)) - { - using var http = _httpFactory.CreateClient(); - data = await http.GetByteArrayAsync(avatarUrl); - using (var avatarImg = Image.Load(data)) - { - avatarImg.Mutate(x => x.Resize(85, 85).ApplyRoundedCorners(42)); - await using var avStream = await avatarImg.ToStreamAsync(); - data = avStream.ToArray(); - DrawAvatar(bg, avatarImg); - } - - await _c.SetImageDataAsync(avatarUrl, data); - } - else - { - using var avatarImg = Image.Load(data); - DrawAvatar(bg, avatarImg); - } - - bg.Mutate(x => x.DrawText( - new TextOptions(_fonts.RipFont) - { - HorizontalAlignment = HorizontalAlignment.Center, - FallbackFontFamilies = _fonts.FallBackFonts, - Origin = new(bg.Width / 2, 225), - }, - text, - Color.Black)); - - //flowa - using (var flowers = Image.Load(await _imgs.GetRipOverlayAsync())) - { - bg.Mutate(x => x.DrawImage(flowers, new(0, 0), new GraphicsOptions())); - } - - await using var stream = bg.ToStream(); - return stream.ToArray(); - } - public async Task GetWeatherDataAsync(string query) { query = query.Trim().ToLowerInvariant(); @@ -396,12 +346,11 @@ public class SearchesService : IEService private async Task GetMovieDataFactory(string name) { using var http = _httpFactory.CreateClient(); - var res = await http.GetStringAsync(string.Format("https://omdbapi.nadeko.bot/" - + "?t={0}" - + "&y=" - + "&plot=full" - + "&r=json", - name.Trim().Replace(' ', '+'))); + var res = await http.GetStringAsync("https://omdbapi.nadeko.bot/" + + $"?t={name.Trim().Replace(' ', '+')}" + + "&y=" + + "&plot=full" + + "&r=json"); var movie = JsonConvert.DeserializeObject(res); if (movie?.Title is null) return null; @@ -467,7 +416,7 @@ public class SearchesService : IEService try { var result = await _c.GetOrAddAsync($"wikipedia_{query}", - async _ => + async () => { using var http = _httpFactory.CreateClient(); http.DefaultRequestHeaders.Clear(); diff --git a/src/EllieBot/Services/Impl/ImageCache.cs b/src/EllieBot/Services/Impl/ImageCache.cs index 12ec051..4fc4e72 100644 --- a/src/EllieBot/Services/Impl/ImageCache.cs +++ b/src/EllieBot/Services/Impl/ImageCache.cs @@ -74,10 +74,4 @@ public sealed class ImageCache : IImageCache, IEService public Task GetSlotBgAsync() => GetImageDataAsync(_ic.Data.Slots.Bg); - - public Task GetRipBgAsync() - => GetImageDataAsync(_ic.Data.Rip.Bg); - - public Task GetRipOverlayAsync() - => GetImageDataAsync(_ic.Data.Rip.Overlay); } \ No newline at end of file diff --git a/src/EllieBot/_common/ImageUrls.cs b/src/EllieBot/_common/ImageUrls.cs index 449043f..5dc9557 100644 --- a/src/EllieBot/_common/ImageUrls.cs +++ b/src/EllieBot/_common/ImageUrls.cs @@ -8,7 +8,7 @@ namespace EllieBot.Common; public partial class ImageUrls : ICloneable { [Comment("DO NOT CHANGE")] - public int Version { get; set; } = 3; + public int Version { get; set; } = 4; public CoinData Coins { get; set; } public Uri[] Currency { get; set; } @@ -16,16 +16,8 @@ public partial class ImageUrls : ICloneable public RategirlData Rategirl { get; set; } public XpData Xp { get; set; } - //new - public RipData Rip { get; set; } public SlotData Slots { get; set; } - public class RipData - { - public Uri Bg { get; set; } - public Uri Overlay { get; set; } - } - public class SlotData { public Uri[] Emojis { get; set; } diff --git a/src/EllieBot/_common/Services/Impl/FontProvider.cs b/src/EllieBot/_common/Services/Impl/FontProvider.cs index 543f23c..2bead90 100644 --- a/src/EllieBot/_common/Services/Impl/FontProvider.cs +++ b/src/EllieBot/_common/Services/Impl/FontProvider.cs @@ -12,11 +12,6 @@ public class FontProvider : IEService public FontFamily NotoSans { get; } //public FontFamily Emojis { get; } - /// - /// Font used for .rip command - /// - public Font RipFont { get; } - public List FallBackFonts { get; } private readonly FontCollection _fonts; @@ -54,7 +49,6 @@ public class FontProvider : IEService FallBackFonts.AddRange(_fonts.AddCollection(font)); } - RipFont = NotoSans.CreateFont(20, FontStyle.Bold); DottyFont = FallBackFonts.First(x => x.Name == "dotty"); } } \ No newline at end of file diff --git a/src/EllieBot/_common/Services/Impl/IImageCache.cs b/src/EllieBot/_common/Services/Impl/IImageCache.cs index 8c8ff32..890eeea 100644 --- a/src/EllieBot/_common/Services/Impl/IImageCache.cs +++ b/src/EllieBot/_common/Services/Impl/IImageCache.cs @@ -11,7 +11,5 @@ public interface IImageCache Task GetDiceAsync(int num); Task GetSlotEmojiAsync(int number); Task GetSlotBgAsync(); - Task GetRipBgAsync(); - Task GetRipOverlayAsync(); Task GetImageDataAsync(Uri url); } \ No newline at end of file diff --git a/src/EllieBot/data/aliases.yml b/src/EllieBot/data/aliases.yml index a6b5e16..d8c13df 100644 --- a/src/EllieBot/data/aliases.yml +++ b/src/EllieBot/data/aliases.yml @@ -1150,8 +1150,6 @@ discordpermoverridereset: - dpor rafflecur: - rafflecur -rip: - - rip timelyset: - timelyset timely: diff --git a/src/EllieBot/data/strings/commands/commands.en-US.yml b/src/EllieBot/data/strings/commands/commands.en-US.yml index 2ba8bc7..ce0f56f 100644 --- a/src/EllieBot/data/strings/commands/commands.en-US.yml +++ b/src/EllieBot/data/strings/commands/commands.en-US.yml @@ -3885,13 +3885,6 @@ rafflecur: desc: "The minimum or maximum amount of currency that can be used for betting." mixed: desc: "The parameter determines whether the raffle operates in \"fixed\" or \"proportional\" mode." -rip: - desc: Shows the inevitable fate of someone. - ex: - - '@Someone' - params: - - usr: - desc: "The user whose fate is being revealed." autodisconnect: desc: Toggles whether the bot should disconnect from the voice channel once it's done playing all of the songs and queue repeat option is set to `none`. ex: