Preloaded images with predictable URLs instead of continually reuploading the webps

This commit is contained in:
barelyprofessional
2026-01-15 23:56:29 -06:00
parent 28a4e71c58
commit 981700e889

View File

@@ -100,7 +100,7 @@ public class CoinflipCommand : ICommand
if (rolled > 0.5 + _houseEdge)
{
// won
var coinflipAnimation = await GetCoinFlipAnimationUrl(choiceStr);
var coinflipAnimation = GetCoinFlipAnimationUrl(choiceStr);
await botInstance.SendChatMessageAsync($"[IMG]{coinflipAnimation}[/IMG]", true, autoDeleteAfter: cleanupDelay);
await Task.Delay(1200, ctx);
@@ -116,7 +116,7 @@ public class CoinflipCommand : ICommand
{
// lost
bool isJacky = rolled > 0.5; // would've won without house edge
var coinflipAnimationURL = await GetCoinFlipAnimationUrl("heads" == choiceStr ? "tails" : "heads", isJacky);
var coinflipAnimationURL = GetCoinFlipAnimationUrl("heads" == choiceStr ? "tails" : "heads", isJacky);
await botInstance.SendChatMessageAsync($"[IMG]{coinflipAnimationURL}[/IMG]", true, autoDeleteAfter: cleanupDelay);
await Task.Delay(1200, ctx);
@@ -129,20 +129,14 @@ public class CoinflipCommand : ICommand
}
}
private static async Task<string?> GetCoinFlipAnimationUrl(string choiceStr, bool isJacky = false)
private static string GetCoinFlipAnimationUrl(string choiceStr, bool isJacky = false)
{
string animationPath;
var baseUrl = "https://i.ddos.lgbt/u";
if (isJacky)
{
animationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", $"bossmancoin-{choiceStr}-jacky.webp");
return $"{baseUrl}/bossmancoin-{choiceStr}-jacky.webp";
}
else
{
animationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets", $"bossmancoin-{choiceStr}.webp");
}
if (!File.Exists(animationPath)) throw new DirectoryNotFoundException($"Coinflip animation missing at {animationPath}");
using var imageStream = File.OpenRead(animationPath);
return await Zipline.Upload(imageStream, new MediaTypeHeaderValue("image/webp"), "1h");
return $"{baseUrl}/bossmancoin-{choiceStr}.webp";
}
}