Adding random images of squirrels, croissants, pumpkins and turtles, combined all in mediaprovider class

This commit is contained in:
Runebaas 2017-10-05 21:42:27 +02:00
parent 0c9a2a5619
commit f30c136785
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
11 changed files with 281 additions and 113 deletions

View file

@ -11,15 +11,15 @@ namespace Geekbot.net.Commands
{
public class CheckEm : ModuleBase
{
private readonly ICheckEmImageProvider checkEmImages;
private readonly IMediaProvider checkEmImages;
private readonly Random rnd;
private readonly ILogger logger;
private readonly IErrorHandler errorHandler;
public CheckEm(Random RandomClient, ICheckEmImageProvider checkEmImages, ILogger logger, IErrorHandler errorHandler)
public CheckEm(Random RandomClient, IMediaProvider mediaProvider, ILogger logger, IErrorHandler errorHandler)
{
this.rnd = RandomClient;
this.checkEmImages = checkEmImages;
this.checkEmImages = mediaProvider;
this.logger = logger;
this.errorHandler = errorHandler;
}
@ -50,7 +50,7 @@ namespace Geekbot.net.Commands
sb.AppendLine($"**{number}**");
if (!string.IsNullOrEmpty(dubtriqua))
sb.AppendLine($":tada: {dubtriqua} :tada:");
sb.AppendLine(checkEmImages.GetRandomCheckEmPic());
sb.AppendLine(checkEmImages.getCheckem());
await ReplyAsync(sb.ToString());
}

View file

@ -1,23 +0,0 @@
using System.Threading.Tasks;
using Discord.Commands;
using Geekbot.net.Lib.Media;
namespace Geekbot.net.Commands
{
public class Panda : ModuleBase
{
private readonly IPandaProvider pandaImages;
public Panda(IPandaProvider pandaImages)
{
this.pandaImages = pandaImages;
}
[Command("panda", RunMode = RunMode.Async)]
[Summary("Get a random panda")]
public async Task PandaCommand()
{
await ReplyAsync(pandaImages.GetRandomPanda());
}
}
}

View file

@ -0,0 +1,52 @@
using System.Threading.Tasks;
using Discord.Commands;
using Geekbot.net.Lib.Media;
namespace Geekbot.net.Commands
{
public class RandomAnimals : ModuleBase
{
private readonly IMediaProvider _mediaProvider;
public RandomAnimals(IMediaProvider mediaProvider)
{
_mediaProvider = mediaProvider;
}
[Command("panda", RunMode = RunMode.Async)]
[Summary("Get a random panda image")]
public async Task panda()
{
await ReplyAsync(_mediaProvider.getPanda());
}
[Command("croissant", RunMode = RunMode.Async)]
[Alias("gipfeli")]
[Summary("Get a random croissant image")]
public async Task croissant()
{
await ReplyAsync(_mediaProvider.getCrossant());
}
[Command("pumpkin", RunMode = RunMode.Async)]
[Summary("Get a random pumpkin image")]
public async Task pumpkin()
{
await ReplyAsync(_mediaProvider.getPumpkin());
}
[Command("squirrel", RunMode = RunMode.Async)]
[Summary("Get a random squirrel image")]
public async Task squirrel()
{
await ReplyAsync(_mediaProvider.getSquirrel());
}
[Command("turtle", RunMode = RunMode.Async)]
[Summary("Get a random turtle image")]
public async Task turtle()
{
await ReplyAsync(_mediaProvider.getTurtle());
}
}
}

View file

@ -1,41 +0,0 @@
using System;
using System.IO;
using Serilog;
namespace Geekbot.net.Lib.Media
{
public class CheckEmImageProvider : ICheckEmImageProvider
{
private readonly string[] checkEmImageArray;
private readonly Random rnd;
private readonly int totalCheckEmImages;
public CheckEmImageProvider(Random rnd, ILogger logger)
{
var path = Path.GetFullPath("./Storage/checkEmPics");
if (File.Exists(path))
{
var rawCheckEmPics = File.ReadAllText(path);
checkEmImageArray = rawCheckEmPics.Split("\n");
totalCheckEmImages = checkEmImageArray.Length;
this.rnd = rnd;
logger.Verbose($"[Geekbot] [CheckEm] Loaded {totalCheckEmImages} CheckEm Images");
}
else
{
logger.Error("checkEmPics File not found");
logger.Error($"Path should be {path}");
}
}
public string GetRandomCheckEmPic()
{
return checkEmImageArray[rnd.Next(0, totalCheckEmImages)];
}
}
public interface ICheckEmImageProvider
{
string GetRandomCheckEmPic();
}
}

View file

@ -0,0 +1,117 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Serilog;
namespace Geekbot.net.Lib.Media
{
public class MediaProvider : IMediaProvider
{
private readonly Random _random;
private readonly ILogger _logger;
private string[] _checkemImages;
private string[] _pandaImages;
private string[] _croissantImages;
private string[] _squirrelImages;
private string[] _pumpkinImages;
private string[] _turtlesImages;
public MediaProvider(Random rnd, ILogger logger)
{
_random = rnd;
_logger = logger;
logger.Information("[Geekbot] Loading Media Files");
loadCheckem();
loadPandas();
bakeCroissants();
loadSquirrels();
loadPumpkins();
loadTurtles();
}
private void loadCheckem()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/checkEmPics"));
_checkemImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_checkemImages.Length} CheckEm Images");
}
private void loadPandas()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pandas"));
_pandaImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_pandaImages.Length} Panda Images");
}
private void bakeCroissants()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/croissant"));
_croissantImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_croissantImages.Length} Croissant Images");
}
private void loadSquirrels()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/squirrel"));
_squirrelImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_squirrelImages.Length} Squirrel Images");
}
private void loadPumpkins()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/pumpkin"));
_pumpkinImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_pumpkinImages.Length} Pumpkin Images");
}
private void loadTurtles()
{
var rawLinks = File.ReadAllText(Path.GetFullPath("./Storage/turtles"));
_turtlesImages = rawLinks.Split("\n");
_logger.Verbose($"[Geekbot] [Media] Loaded {_turtlesImages.Length} Turtle Images");
}
public string getCheckem()
{
return _checkemImages[_random.Next(0, _checkemImages.Length)];
}
public string getPanda()
{
return _pandaImages[_random.Next(0, _pandaImages.Length)];
}
public string getCrossant()
{
return _croissantImages[_random.Next(0, _croissantImages.Length)];
}
public string getSquirrel()
{
return _squirrelImages[_random.Next(0, _squirrelImages.Length)];
}
public string getPumpkin()
{
return _pumpkinImages[_random.Next(0, _pumpkinImages.Length)];
}
public string getTurtle()
{
return _turtlesImages[_random.Next(0, _turtlesImages.Length)];
}
}
public interface IMediaProvider
{
string getCheckem();
string getPanda();
string getCrossant();
string getSquirrel();
string getPumpkin();
string getTurtle();
}
}

View file

@ -1,41 +0,0 @@
using System;
using System.IO;
using Serilog;
namespace Geekbot.net.Lib.Media
{
public class PandaProvider : IPandaProvider
{
private readonly string[] PandaArray;
private readonly Random rnd;
private readonly int totalPandas;
public PandaProvider(Random rnd, ILogger logger)
{
var path = Path.GetFullPath("./Storage/pandas");
if (File.Exists(path))
{
var rawFortunes = File.ReadAllText(path);
PandaArray = rawFortunes.Split("\n");
totalPandas = PandaArray.Length;
this.rnd = rnd;
logger.Verbose($"[Geekbot] [Pandas] Loaded {totalPandas} Panda Images");
}
else
{
logger.Error("Pandas File not found");
logger.Error($"Path should be {path}");
}
}
public string GetRandomPanda()
{
return PandaArray[rnd.Next(0, totalPandas)];
}
}
public interface IPandaProvider
{
string GetRandomPanda();
}
}

View file

@ -107,8 +107,7 @@ namespace Geekbot.net
var errorHandler = new ErrorHandler(logger);
var RandomClient = new Random();
var fortunes = new FortunesProvider(RandomClient, logger);
var checkEmImages = new CheckEmImageProvider(RandomClient, logger);
var pandaImages = new PandaProvider(RandomClient, logger);
var mediaProvider = new MediaProvider(RandomClient, logger);
var malClient = new MalClient(redis, logger);
services.AddSingleton<IErrorHandler>(errorHandler);
@ -117,8 +116,7 @@ namespace Geekbot.net
services.AddSingleton<IUserRepository>(userRepository);
services.AddSingleton(RandomClient);
services.AddSingleton<IFortunesProvider>(fortunes);
services.AddSingleton<ICheckEmImageProvider>(checkEmImages);
services.AddSingleton<IPandaProvider>(pandaImages);
services.AddSingleton<IMediaProvider>(mediaProvider);
services.AddSingleton<IMalClient>(malClient);
logger.Information("[Geekbot] Connecting to Discord");

View file

@ -0,0 +1,17 @@
https://i2.wp.com/epicureandculture.com/wp-content/uploads/2014/12/shutterstock_172040546.jpg
http://www.bakespace.com/images/large/5d79070cf21b2f33c3a1dd4336cb27d2.jpeg
http://food.fnr.sndimg.com/content/dam/images/food/fullset/2015/5/7/1/SD1B43_croissants-recipe_s4x3.jpg.rend.hgtvcom.616.462.suffix/1431052139248.jpeg
http://img.taste.com.au/u-Bwjfm_/taste/2016/11/mini-croissants-with-3-fillings-14692-1.jpeg
https://media.newyorker.com/photos/590974702179605b11ad8096/16:9/w_1200,h_630,c_limit/Gopnik-TheMurkyMeaningsofStraightenedOutCroissants.jpg
http://bt.static-redmouse.ch/sites/bielertagblatt.ch/files/styles/bt_article_showroom_landscape/hash/84/c9/84c9aed08415265911ec05c46d25d3ef.jpg?itok=hP5PnHaT
https://www.dermann.at/wp-content/uploads/Schokocroissant_HPBild_1400x900px.jpeg
https://www.bettybossi.ch/static/rezepte/x/bb_bkxx060101_0360a_x.jpg
http://www.engel-beck.ch/uploads/pics/tete-de-moine-gipfel-.jpg
https://storage.cpstatic.ch/storage/og_image/laugengipfel--425319.jpg
https://www.backhaus-kutzer.de/fileadmin/templates/Resources/Public/img/produkte/suesses-gebaeck/Milchhoernchen.png
https://www.kuechengoetter.de/uploads/media/1000x524/00/36390-vanillekipferl-0.jpg?v=1-0
https://c1.staticflickr.com/3/2835/10874180753_2b2916e3ce_b.jpg
http://www.mistercool.ch/wp-content/uploads/2017/02/Gipfel-mit-Cerealien-7168.png
https://scontent-sea1-1.cdninstagram.com/t51.2885-15/s480x480/e35/c40.0.999.999/15099604_105396696611384_2866237281000226816_n.jpg?ig_cache_key=MTM4MzQxOTU1MDc5NjUxNzcwMA%3D%3D.2.c
http://www.lecrobag.de/wp-content/uploads/2014/03/Wurst_2014_l.jpg
https://www.thecookierookie.com/wp-content/uploads/2017/02/sheet-pan-chocolate-croissants-collage1.jpeg

View file

@ -0,0 +1,23 @@
https://i.pinimg.com/736x/0a/a7/8a/0aa78af25e114836e1a42585fb7b09ed--funny-pumpkins-pumkin-carving.jpg
http://wdy.h-cdn.co/assets/16/31/980x1470/gallery-1470321728-shot-two-021.jpg
https://i.pinimg.com/736x/6c/62/bf/6c62bfa73a19ffd9fc6f2d720d5e9764--cool-pumpkin-carving-carving-pumpkins.jpg
http://images6.fanpop.com/image/photos/38900000/Jack-o-Lantern-halloween-38991566-500-415.jpg
http://ghk.h-cdn.co/assets/15/37/1441834730-pumpkin-carve-2.jpg
http://diy.sndimg.com/content/dam/images/diy/fullset/2011/7/26/1/iStock-10761186_halloween-pumpkin-in-garden_s4x3.jpg.rend.hgtvcom.966.725.suffix/1420851319631.jpeg
http://ghk.h-cdn.co/assets/cm/15/11/54ffe537af882-snail-pumpkin-de.jpg
https://www.digsdigs.com/photos/2009/10/100-halloween-pumpkin-carving-ideas-12.jpg
http://diy.sndimg.com/content/dam/images/diy/fullset/2010/6/4/0/CI-Kyle-Nishioka_big-teeth-Jack-O-Lantern_s4x3.jpg.rend.hgtvcom.966.725.suffix/1420699522718.jpeg
https://twistedsifter.files.wordpress.com/2011/10/most-amazing-pumpkin-carving-ray-villafane-10.jpg?w=521&h=739
https://i.pinimg.com/736x/09/c4/b1/09c4b187b266c1f65332294f66009944--funny-pumpkins-halloween-pumpkins.jpg
http://www.evilmilk.com/pictures/The_Pumpkin_Man.jpg
http://cache.lovethispic.com/uploaded_images/blogs/13-Funny-Pumpkin-Carvings-5773-9.JPG
http://ihappyhalloweenpictures.com/wp-content/uploads/2016/10/funny-halloween-pumpkin.jpg
http://www.smallhomelove.com/wp-content/uploads/2012/08/leg-eating-pumpkin.jpg
https://cdn.shopify.com/s/files/1/0773/6789/articles/Halloween_Feature_8ff7a7c4-2cb3-4584-a85f-5d4d1e6ca26e.jpg?v=1476211360
http://4vector.com/i/free-vector-pumpkin-boy-color-version-clip-art_107714_Pumpkin_Boy_Color_Version_clip_art_hight.png
https://i.pinimg.com/736x/59/8a/0f/598a0fbf789631b76c1ffd4443194d8e--halloween-pumpkins-fall-halloween.jpg
https://i.pinimg.com/originals/8f/86/f9/8f86f95457467872b371ba697d341961.jpg
http://nerdist.com/wp-content/uploads/2015/08/taleshalloween1.jpg
http://www.designbolts.com/wp-content/uploads/2014/09/Scary-Pumpkin_Grin_stencil-Ideas.jpg
http://vignette2.wikia.nocookie.net/scoobydoo/images/7/75/Pumpkin_monsters_%28Witch%27s_Ghost%29.png/revision/latest?cb=20140520070213
https://taholtorf.files.wordpress.com/2013/10/36307-1920x1280.jpg

View file

@ -0,0 +1,45 @@
http://orig14.deviantart.net/6016/f/2010/035/c/b/first_squirrel_assassin_by_shotokanteddy.jpg
https://thumbs-prod.si-cdn.com/eoEYA_2Hau4795uKoecUZZgz-3w=/800x600/filters:no_upscale()/https://public-media.smithsonianmag.com/filer/52/f9/52f93262-c29b-4a4f-b031-0c7ad145ed5f/42-33051942.jpg
http://images5.fanpop.com/image/photos/30700000/Squirrel-squirrels-30710732-400-300.jpg
https://www.lovethegarden.com/sites/default/files/files/Red%20%26%20Grey%20Squirrel%20picture%20side%20by%20side-LR.jpg
http://i.dailymail.co.uk/i/pix/2016/02/24/16/158F7E7C000005DC-3462228-image-a-65_1456331226865.jpg
http://2.bp.blogspot.com/-egfnMhUb8tg/T_dAIu1m6cI/AAAAAAAAPPU/v4x9q4WqWl8/s640/cute-squirrel-hey-watcha-thinkin-about.jpg
https://upload.wikimedia.org/wikipedia/commons/thumb/1/1c/Squirrel_posing.jpg/287px-Squirrel_posing.jpg
https://i.pinimg.com/736x/51/db/9b/51db9bad4a87d445d321923c7d56b501--red-squirrel-animal-kingdom.jpg
https://metrouk2.files.wordpress.com/2016/10/ad_223291521.jpg?w=620&h=949&crop=1
http://www.redsquirrelsunited.org.uk/wp-content/uploads/2016/07/layer-slider.jpg
http://images.mentalfloss.com/sites/default/files/squirrel-hero.jpg?resize=1100x740
https://i.pinimg.com/736x/ce/9c/59/ce9c5990b193046400d98724595cdaf3--red-squirrel-chipmunks.jpg
https://www.brooklynpaper.com/assets/photos/40/30/dtg-squirrel-attacks-prospect-park-patrons-2017-07-28-bk01_z.jpg
http://www.freakingnews.com/pictures/16000/Squirrel-Shark-16467.jpg
http://img09.deviantart.net/5c1c/i/2013/138/0/6/barbarian_squirel_by_coucoucmoa-d64r9m4.jpg
https://i.pinimg.com/736x/b4/5c/0d/b45c0d00b1a57e9f84f27f13cb019001--baby-squirrel-red-squirrel.jpg
https://i.pinimg.com/736x/0f/75/87/0f7587bb613ab524763afe8c9a532e5c--cute-squirrel-squirrels.jpg
http://cdn.images.express.co.uk/img/dynamic/128/590x/Grey-squirrel-828838.jpg
http://www.lovethispic.com/uploaded_images/79964-Squirrel-Smelling-A-Flower.jpg
https://i.pinimg.com/736x/23/d5/f9/23d5f9868f7d76c79c49bef53ae08f7f--squirrel-funny-red-squirrel.jpg
http://stories.barkpost.com/wp-content/uploads/2016/01/squirrel-3-copy.jpg
https://i.ytimg.com/vi/pzUs0DdzK3Y/hqdefault.jpg
https://www.askideas.com/media/41/I-Swear-It-Wasnt-Me-Funny-Squirrel-Meme-Picture-For-Facebook.jpg
https://i.pinimg.com/736x/2d/54/d8/2d54d8d2a9b3ab9d3e78544b75afd88e--funny-animal-pictures-humorous-pictures.jpg
http://www.funny-animalpictures.com/media/content/items/images/funnysquirrels0012_O.jpg
http://funny-pics.co/wp-content/uploads/funny-squirrel-and-coffee-picture.jpg
https://pbs.twimg.com/media/Bi4Ij6CIgAAgEdZ.jpg
http://www.funnyjunksite.com/pictures/wp-content/uploads/2015/06/Funny-Superman-Squirrels.jpg
https://i.pinimg.com/736x/bf/35/00/bf3500104f8394909d116259d1f0575e--funny-squirrel-squirrel-girl.jpg
http://quotespill.com/wp-content/uploads/2017/07/Squirrel-Meme-Draw-me-like-one-of-your-french-squirrrels-min.jpg
https://i.pinimg.com/736x/e2/16/bb/e216bba53f80fc8e0111d371e9850159--funny-squirrels-cute-squirrel.jpg
https://i.pinimg.com/736x/52/43/c9/5243c93377245be1f686218c266d775c--funny-squirrel-baby-squirrel.jpg
https://i.pinimg.com/736x/0c/be/1d/0cbe1da8ad2c0cf3882a806b6fd88965--cute-pictures-funny-animal-pictures.jpg
https://i.pinimg.com/736x/e5/08/67/e508670aa00ca3c896eccb81c4f6e2a8--funny-squirrel-baby-squirrel.jpg
https://i.pinimg.com/736x/1c/7d/4f/1c7d4f067a10066aad802ce5ac468d71--group-boards-a-squirrel.jpg
http://funny-pics.co/wp-content/uploads/funny-squirrel-on-a-branch.jpg
http://loldamn.com/wp-content/uploads/2016/06/funny-squirrel-playing-water-bending.jpg
https://cdn.trendhunterstatic.com/thumbs/squirrel-photography.jpeg
https://i.pinimg.com/736x/d6/42/12/d64212cc6221916db4173962bf6c131a--cute-squirrel-baby-squirrel.jpg
https://i.pinimg.com/236x/10/13/58/101358f2afc2c7d6b6a668046e7b8382--funny-animal-pictures-funny-animals.jpg
https://i.pinimg.com/736x/da/0d/fe/da0dfe93bb26887795f906e8fa97d68e--secret-squirrel-cute-squirrel.jpg
http://2.bp.blogspot.com/-HLieBqEuQoM/UDkRmeyzB5I/AAAAAAAABHs/RtsEynn5t6Y/s1600/hd-squirrel-wallpaper-with-a-brown-squirrel-eating-watermelon-wallpapers-backgrounds-pictures-photos.jpg
http://www.city-data.com/forum/members/brenda-starz-328928-albums-brenda-s-funny-squirrel-comment-pic-s-pic5075-punk-squirrels.jpg
http://img15.deviantart.net/9c50/i/2011/213/c/9/just_taking_it_easy_by_lou_in_canada-d42do3d.jpg
http://3.bp.blogspot.com/-AwsSk76R2Is/USQa3-dszKI/AAAAAAAABUQ/KF_F8HbtP1U/w1200-h630-p-k-no-nu/crazySquirrel.jpg

View file

@ -0,0 +1,21 @@
https://i.guim.co.uk/img/media/6b9be13031738e642f93f9271f3592044726a9b1/0_0_2863_1610/2863.jpg?w=640&h=360&q=55&auto=format&usm=12&fit=max&s=85f3b33cc158b5aa120c143dae1916ed
http://cf.ltkcdn.net/small-pets/images/std/212089-676x450-Turtle-feeding-on-leaf.jpg
https://static1.squarespace.com/static/5369465be4b0507a1fd05af0/53767a6be4b0ad0822345e52/57e40ba4893fc031e05a018f/1498243318058/solvin.jpg?format=1500w
https://c402277.ssl.cf1.rackcdn.com/photos/419/images/story_full_width/HI_287338Hero.jpg?1433950119
https://www.cdc.gov/salmonella/agbeni-08-17/images/turtle.jpg
https://cdn.arstechnica.net/wp-content/uploads/2017/08/GettyImages-524757168.jpg
http://pmdvod.nationalgeographic.com/NG_Video/595/319/4504517_098_05_TOS_thumbnail_640x360_636296259676.jpg
http://cdn1.arkive.org/media/7D/7D46329A-6ED2-4F08-909E-7B596417994A/Presentation.Large/Big-headed-turtle-close-up.jpg
http://s7d2.scene7.com/is/image/PetSmart/ARTHMB-CleaningYourTortoiseOrTurtlesHabitat-20160818?$AR1104$
https://fthmb.tqn.com/9VGWzK_GWlvrjxtdFPX6EJxOq24=/960x0/filters:no_upscale()/133605352-56a2bce53df78cf7727960db.jpg
https://i.imgur.com/46QmzgF.jpg
https://www.wildgratitude.com/wp-content/uploads/2015/07/turtle-spirit-animal1.jpg
http://www.backwaterreptiles.com/images/turtles/red-eared-slider-turtle-for-sale.jpg
https://i.pinimg.com/736x/f1/f4/13/f1f413d6d07912be6080c08b186630ac--happy-turtle-funny-stuff.jpg
http://www.dupageforest.org/uploadedImages/Content/District_News/Nature_Stories/2016/Snapping%20Turtle%20Scott%20Plantier%20STP4793.jpg
http://turtlebackzoo.com/wp-content/uploads/2016/07/exhibit-headers_0008_SOUTH-AMERICA-600x400.jpg
https://i.ytimg.com/vi/_YfYHFM3Das/maxresdefault.jpg
https://i.pinimg.com/736x/dd/4e/7f/dd4e7f2f921ac28b1d5a59174d477131--cute-baby-sea-turtles-adorable-turtles.jpg
http://kids.nationalgeographic.com/content/dam/kids/photos/animals/Reptiles/A-G/green-sea-turtle-closeup-underwater.adapt.945.1.jpg
https://i.ytimg.com/vi/p4Jj9QZFJvw/hqdefault.jpg
https://fthmb.tqn.com/nirxHkH3jBAe74ife6fJJu6k6q8=/2121x1414/filters:fill(auto,1)/Red-eared-sliders-GettyImages-617946009-58fae8835f9b581d59a5bab6.jpg