Now with 100% more pinguins

This commit is contained in:
runebaas 2018-03-28 21:28:16 +02:00
parent 75cbcfff76
commit 6bc6fb69af
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
4 changed files with 53 additions and 5 deletions

View file

@ -1,4 +1,5 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.Media; using Geekbot.net.Lib.Media;
@ -19,7 +20,7 @@ namespace Geekbot.net.Commands
[Summary("Get a random panda image")] [Summary("Get a random panda image")]
public async Task panda() public async Task panda()
{ {
await ReplyAsync(_mediaProvider.getPanda()); await ReplyAsync("", false, eb(_mediaProvider.getPanda()));
} }
[Command("croissant", RunMode = RunMode.Async)] [Command("croissant", RunMode = RunMode.Async)]
@ -28,7 +29,7 @@ namespace Geekbot.net.Commands
[Summary("Get a random croissant image")] [Summary("Get a random croissant image")]
public async Task croissant() public async Task croissant()
{ {
await ReplyAsync(_mediaProvider.getCrossant()); await ReplyAsync("", false, eb(_mediaProvider.getCrossant()));
} }
[Command("pumpkin", RunMode = RunMode.Async)] [Command("pumpkin", RunMode = RunMode.Async)]
@ -36,7 +37,7 @@ namespace Geekbot.net.Commands
[Summary("Get a random pumpkin image")] [Summary("Get a random pumpkin image")]
public async Task pumpkin() public async Task pumpkin()
{ {
await ReplyAsync(_mediaProvider.getPumpkin()); await ReplyAsync("", false, eb(_mediaProvider.getPumpkin()));
} }
[Command("squirrel", RunMode = RunMode.Async)] [Command("squirrel", RunMode = RunMode.Async)]
@ -44,7 +45,7 @@ namespace Geekbot.net.Commands
[Summary("Get a random squirrel image")] [Summary("Get a random squirrel image")]
public async Task squirrel() public async Task squirrel()
{ {
await ReplyAsync(_mediaProvider.getSquirrel()); await ReplyAsync("", false, eb(_mediaProvider.getSquirrel()));
} }
[Command("turtle", RunMode = RunMode.Async)] [Command("turtle", RunMode = RunMode.Async)]
@ -52,7 +53,23 @@ namespace Geekbot.net.Commands
[Summary("Get a random turtle image")] [Summary("Get a random turtle image")]
public async Task turtle() 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;
} }
} }
} }

View file

@ -69,5 +69,8 @@
<None Update="Storage\turtles"> <None Update="Storage\turtles">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Update="Storage\pinguins">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -16,6 +16,7 @@ namespace Geekbot.net.Lib.Media
private string[] _squirrelImages; private string[] _squirrelImages;
private string[] _pumpkinImages; private string[] _pumpkinImages;
private string[] _turtlesImages; private string[] _turtlesImages;
private string[] _pinguinImages;
public MediaProvider(IGeekbotLogger logger) public MediaProvider(IGeekbotLogger logger)
{ {
@ -30,6 +31,7 @@ namespace Geekbot.net.Lib.Media
LoadSquirrels(); LoadSquirrels();
LoadPumpkins(); LoadPumpkins();
LoadTurtles(); LoadTurtles();
LoadPinguins();
} }
private void LoadCheckem() private void LoadCheckem()
@ -74,6 +76,13 @@ namespace Geekbot.net.Lib.Media
_logger.Debug("Geekbot", $"Loaded {_turtlesImages.Length} Turtle Images"); _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() public string getCheckem()
{ {
return _checkemImages[_random.Next(0, _checkemImages.Length)]; return _checkemImages[_random.Next(0, _checkemImages.Length)];
@ -103,6 +112,11 @@ namespace Geekbot.net.Lib.Media
{ {
return _turtlesImages[_random.Next(0, _turtlesImages.Length)]; return _turtlesImages[_random.Next(0, _turtlesImages.Length)];
} }
public string getPinguin()
{
return _pinguinImages[_random.Next(0, _pinguinImages.Length)];
}
} }
public interface IMediaProvider public interface IMediaProvider
@ -113,5 +127,6 @@ namespace Geekbot.net.Lib.Media
string getSquirrel(); string getSquirrel();
string getPumpkin(); string getPumpkin();
string getTurtle(); string getTurtle();
string getPinguin();
} }
} }

View file

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