Removed .rip command

This commit is contained in:
Toastie (DCS Team) 2024-07-29 18:32:34 +12:00
parent 86b015115a
commit 20e5bbac89
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
8 changed files with 7 additions and 99 deletions

View file

@ -39,16 +39,6 @@ public partial class Searches : EllieModule<SearchesService>
_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)
{

View file

@ -73,56 +73,6 @@ public class SearchesService : IEService
}
}
public async Task<Stream> 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<byte[]> GetRipPictureFactory(string text, Uri avatarUrl)
{
using var bg = Image.Load<Rgba32>(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<Rgba32>(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<Rgba32>(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<WeatherData> GetWeatherDataAsync(string query)
{
query = query.Trim().ToLowerInvariant();
@ -396,12 +346,11 @@ public class SearchesService : IEService
private async Task<OmdbMovie> GetMovieDataFactory(string name)
{
using var http = _httpFactory.CreateClient();
var res = await http.GetStringAsync(string.Format("https://omdbapi.nadeko.bot/"
+ "?t={0}"
var res = await http.GetStringAsync("https://omdbapi.nadeko.bot/"
+ $"?t={name.Trim().Replace(' ', '+')}"
+ "&y="
+ "&plot=full"
+ "&r=json",
name.Trim().Replace(' ', '+')));
+ "&r=json");
var movie = JsonConvert.DeserializeObject<OmdbMovie>(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();

View file

@ -74,10 +74,4 @@ public sealed class ImageCache : IImageCache, IEService
public Task<byte[]?> GetSlotBgAsync()
=> GetImageDataAsync(_ic.Data.Slots.Bg);
public Task<byte[]?> GetRipBgAsync()
=> GetImageDataAsync(_ic.Data.Rip.Bg);
public Task<byte[]?> GetRipOverlayAsync()
=> GetImageDataAsync(_ic.Data.Rip.Overlay);
}

View file

@ -8,7 +8,7 @@ namespace EllieBot.Common;
public partial class ImageUrls : ICloneable<ImageUrls>
{
[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<ImageUrls>
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; }

View file

@ -12,11 +12,6 @@ public class FontProvider : IEService
public FontFamily NotoSans { get; }
//public FontFamily Emojis { get; }
/// <summary>
/// Font used for .rip command
/// </summary>
public Font RipFont { get; }
public List<FontFamily> 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");
}
}

View file

@ -11,7 +11,5 @@ public interface IImageCache
Task<byte[]?> GetDiceAsync(int num);
Task<byte[]?> GetSlotEmojiAsync(int number);
Task<byte[]?> GetSlotBgAsync();
Task<byte[]?> GetRipBgAsync();
Task<byte[]?> GetRipOverlayAsync();
Task<byte[]?> GetImageDataAsync(Uri url);
}

View file

@ -1150,8 +1150,6 @@ discordpermoverridereset:
- dpor
rafflecur:
- rafflecur
rip:
- rip
timelyset:
- timelyset
timely:

View file

@ -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: