From 6bc6fb69afefd5f28dbd0fb08c26c2196f17c411 Mon Sep 17 00:00:00 2001 From: runebaas Date: Wed, 28 Mar 2018 21:28:16 +0200 Subject: [PATCH] Now with 100% more pinguins --- Geekbot.net/Commands/RandomAnimals.cs | 27 +++++++++++++++++++++----- Geekbot.net/Geekbot.net.csproj | 3 +++ Geekbot.net/Lib/Media/MediaProvider.cs | 15 ++++++++++++++ Geekbot.net/Storage/pinguins | 13 +++++++++++++ 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 Geekbot.net/Storage/pinguins diff --git a/Geekbot.net/Commands/RandomAnimals.cs b/Geekbot.net/Commands/RandomAnimals.cs index 29930eb..84f0323 100644 --- a/Geekbot.net/Commands/RandomAnimals.cs +++ b/Geekbot.net/Commands/RandomAnimals.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Discord; using Discord.Commands; using Geekbot.net.Lib; using Geekbot.net.Lib.Media; @@ -19,7 +20,7 @@ namespace Geekbot.net.Commands [Summary("Get a random panda image")] public async Task panda() { - await ReplyAsync(_mediaProvider.getPanda()); + await ReplyAsync("", false, eb(_mediaProvider.getPanda())); } [Command("croissant", RunMode = RunMode.Async)] @@ -28,7 +29,7 @@ namespace Geekbot.net.Commands [Summary("Get a random croissant image")] public async Task croissant() { - await ReplyAsync(_mediaProvider.getCrossant()); + await ReplyAsync("", false, eb(_mediaProvider.getCrossant())); } [Command("pumpkin", RunMode = RunMode.Async)] @@ -36,7 +37,7 @@ namespace Geekbot.net.Commands [Summary("Get a random pumpkin image")] public async Task pumpkin() { - await ReplyAsync(_mediaProvider.getPumpkin()); + await ReplyAsync("", false, eb(_mediaProvider.getPumpkin())); } [Command("squirrel", RunMode = RunMode.Async)] @@ -44,7 +45,7 @@ namespace Geekbot.net.Commands [Summary("Get a random squirrel image")] public async Task squirrel() { - await ReplyAsync(_mediaProvider.getSquirrel()); + await ReplyAsync("", false, eb(_mediaProvider.getSquirrel())); } [Command("turtle", RunMode = RunMode.Async)] @@ -52,7 +53,23 @@ namespace Geekbot.net.Commands [Summary("Get a random turtle image")] public async Task turtle() { - await ReplyAsync(_mediaProvider.getTurtle()); + await ReplyAsync("", false, eb(_mediaProvider.getTurtle())); + } + + [Command("pinguin", RunMode = RunMode.Async)] + [Alias("pingu")] + [Remarks(CommandCategories.Randomness)] + [Summary("Get a random turtle image")] + public async Task pinguin() + { + await ReplyAsync("", false, eb(_mediaProvider.getPinguin())); + } + + private EmbedBuilder eb(string image) + { + var eb = new EmbedBuilder(); + eb.ImageUrl = image; + return eb; } } } \ No newline at end of file diff --git a/Geekbot.net/Geekbot.net.csproj b/Geekbot.net/Geekbot.net.csproj index 89aab56..0a772d8 100755 --- a/Geekbot.net/Geekbot.net.csproj +++ b/Geekbot.net/Geekbot.net.csproj @@ -69,5 +69,8 @@ PreserveNewest + + PreserveNewest + \ No newline at end of file diff --git a/Geekbot.net/Lib/Media/MediaProvider.cs b/Geekbot.net/Lib/Media/MediaProvider.cs index 0a3ff6c..2f0204e 100644 --- a/Geekbot.net/Lib/Media/MediaProvider.cs +++ b/Geekbot.net/Lib/Media/MediaProvider.cs @@ -16,6 +16,7 @@ namespace Geekbot.net.Lib.Media private string[] _squirrelImages; private string[] _pumpkinImages; private string[] _turtlesImages; + private string[] _pinguinImages; public MediaProvider(IGeekbotLogger logger) { @@ -30,6 +31,7 @@ namespace Geekbot.net.Lib.Media LoadSquirrels(); LoadPumpkins(); LoadTurtles(); + LoadPinguins(); } private void LoadCheckem() @@ -74,6 +76,13 @@ namespace Geekbot.net.Lib.Media _logger.Debug("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images"); } + private void LoadPinguins() + { + var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pinguins")); + _pinguinImages = rawLinks.Split("\n"); + _logger.Debug("Geekbot", $"Loaded {_pinguinImages.Length} Pinguin Images"); + } + public string getCheckem() { return _checkemImages[_random.Next(0, _checkemImages.Length)]; @@ -103,6 +112,11 @@ namespace Geekbot.net.Lib.Media { return _turtlesImages[_random.Next(0, _turtlesImages.Length)]; } + + public string getPinguin() + { + return _pinguinImages[_random.Next(0, _pinguinImages.Length)]; + } } public interface IMediaProvider @@ -113,5 +127,6 @@ namespace Geekbot.net.Lib.Media string getSquirrel(); string getPumpkin(); string getTurtle(); + string getPinguin(); } } \ No newline at end of file diff --git a/Geekbot.net/Storage/pinguins b/Geekbot.net/Storage/pinguins new file mode 100644 index 0000000..631f9d0 --- /dev/null +++ b/Geekbot.net/Storage/pinguins @@ -0,0 +1,13 @@ +https://i.ytimg.com/vi/Qr6sULJnu2o/maxresdefault.jpg +https://www.apex-expeditions.com/wp-content/uploads/2015/08/newzealandSlider_Macquarie_ElephantSealKingPenguins_GRiehle_1366x601.jpg +https://www.birdlife.org/sites/default/files/styles/1600/public/slide.jpg?itok=HRhQfA1S +http://experimentexchange.com/wp-content/uploads/2016/07/penguins-fact.jpg +http://images.mentalfloss.com/sites/default/files/styles/mf_image_16x9/public/istock-511366776.jpg?itok=cWhdWNZ8&resize=1100x619 +https://www.thevaporplace.ch/media/catalog/product/cache/1/thumbnail/800x800/9df78eab33525d08d6e5fb8d27136e95/a/t/atopack_penguin-15.jpg +https://www.superfastbusiness.com/wp-content/uploads/2015/10/real-time-penguin-algorithm-featured.jpg +http://www.antarctica.gov.au/__data/assets/image/0011/147737/varieties/antarctic.jpg +https://vignette.wikia.nocookie.net/robloxcreepypasta/images/1/11/AAEAAQAAAAAAAAdkAAAAJDc3YzkyYjJhLTYyZjctNDY2Mi04M2VjLTg4NjY4ZjgwYzRmNg.png/revision/latest?cb=20180207200526 +https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR3xV0lhpZuhT8Nmm6LaITsppZ7VfWcWXuyu2cPHrlv_dt_M92K5g +http://goboiano.com/wp-content/uploads/2017/04/Penguin-Kemeno-Friends-Waifu.jpg +https://cdn.yoast.com/app/uploads/2015/10/Penguins_1200x628.png +https://images.justwatch.com/backdrop/8611153/s1440/pingu \ No newline at end of file