From 1295ed6206d2c8e2dbc509e80a59a1c6dc102831 Mon Sep 17 00:00:00 2001 From: Runebaas Date: Fri, 15 Sep 2017 12:58:49 +0200 Subject: [PATCH] Add Checkem Command --- Geekbot.net/Lib/CheckEmImageProvider.cs | 40 ++++++ .../Lib/{Fortunes.cs => FortunesProvider.cs} | 9 +- Geekbot.net/Modules/CheckEm.cs | 38 ++++++ Geekbot.net/Modules/Fortune.cs | 4 +- Geekbot.net/Program.cs | 6 +- Geekbot.net/Storage/checkEmPics | 122 ++++++++++++++++++ Geekbot.net/{ => Storage}/fortunes | 0 7 files changed, 211 insertions(+), 8 deletions(-) create mode 100644 Geekbot.net/Lib/CheckEmImageProvider.cs rename Geekbot.net/Lib/{Fortunes.cs => FortunesProvider.cs} (77%) create mode 100644 Geekbot.net/Modules/CheckEm.cs create mode 100644 Geekbot.net/Storage/checkEmPics rename Geekbot.net/{ => Storage}/fortunes (100%) diff --git a/Geekbot.net/Lib/CheckEmImageProvider.cs b/Geekbot.net/Lib/CheckEmImageProvider.cs new file mode 100644 index 0000000..823d349 --- /dev/null +++ b/Geekbot.net/Lib/CheckEmImageProvider.cs @@ -0,0 +1,40 @@ +using System; +using System.IO; + +namespace Geekbot.net.Lib +{ + public class CheckEmImageProvider : ICheckEmImageProvider + { + private string[] checkEmImageArray; + private int totalCheckEmImages; + private Random rnd; + + public CheckEmImageProvider() + { + var path = Path.GetFullPath("./Storage/checkEmPics"); + if (File.Exists(path)) + { + var rawCheckEmPics = File.ReadAllText(path); + checkEmImageArray = rawCheckEmPics.Split("\n"); + totalCheckEmImages = checkEmImageArray.Length; + rnd = new Random(); + Console.WriteLine($"- Loaded {totalCheckEmImages} CheckEm Images"); + } + else + { + Console.WriteLine("checkEmPics File not found"); + Console.WriteLine($"Path should be {path}"); + } + } + + public string GetRandomCheckEmPic() + { + return checkEmImageArray[rnd.Next(0, totalCheckEmImages)]; + } + } + + public interface ICheckEmImageProvider + { + string GetRandomCheckEmPic(); + } +} \ No newline at end of file diff --git a/Geekbot.net/Lib/Fortunes.cs b/Geekbot.net/Lib/FortunesProvider.cs similarity index 77% rename from Geekbot.net/Lib/Fortunes.cs rename to Geekbot.net/Lib/FortunesProvider.cs index 15cc710..b11c368 100644 --- a/Geekbot.net/Lib/Fortunes.cs +++ b/Geekbot.net/Lib/FortunesProvider.cs @@ -6,21 +6,22 @@ using System.Text.RegularExpressions; namespace Geekbot.net.Lib { - class Fortunes : IFortunes + class FortunesProvider : IFortunesProvider { private string[] fortuneArray; private int totalFortunes; private Random rnd; - public Fortunes() + public FortunesProvider() { - var path = Path.GetFullPath("./fortunes"); + var path = Path.GetFullPath("./Storage/fortunes"); if (File.Exists(path)) { var rawFortunes= File.ReadAllText(path); fortuneArray = rawFortunes.Split("%"); totalFortunes = fortuneArray.Length; rnd = new Random(); + Console.WriteLine($"- Loaded {totalFortunes} Fortunes"); } else { @@ -40,7 +41,7 @@ namespace Geekbot.net.Lib } } - public interface IFortunes + public interface IFortunesProvider { string GetRandomFortune(); string GetFortune(int id); diff --git a/Geekbot.net/Modules/CheckEm.cs b/Geekbot.net/Modules/CheckEm.cs new file mode 100644 index 0000000..6c5d45f --- /dev/null +++ b/Geekbot.net/Modules/CheckEm.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Discord.Commands; +using Geekbot.net.Lib; + +namespace Geekbot.net.Modules +{ + public class CheckEm : ModuleBase + { + private readonly Random rnd; + private readonly ICheckEmImageProvider checkEmImages; + public CheckEm(Random RandomClient, ICheckEmImageProvider checkEmImages) + { + this.rnd = RandomClient; + this.checkEmImages = checkEmImages; + } + [Command("checkem", RunMode = RunMode.Async), Summary("Check for dubs")] + public async Task MuhDubs() + { + try + { + var sb = new StringBuilder(); + + sb.AppendLine($"Check em {Context.User.Mention}"); + sb.AppendLine($"**{rnd.Next(100000, 99999999)}**"); + sb.AppendLine(checkEmImages.GetRandomCheckEmPic()); + + await ReplyAsync(sb.ToString()); + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + } +} \ No newline at end of file diff --git a/Geekbot.net/Modules/Fortune.cs b/Geekbot.net/Modules/Fortune.cs index c898750..b4e4b07 100644 --- a/Geekbot.net/Modules/Fortune.cs +++ b/Geekbot.net/Modules/Fortune.cs @@ -7,8 +7,8 @@ namespace Geekbot.net.Modules { public class Fortune : ModuleBase { - private readonly IFortunes fortunes; - public Fortune(IFortunes fortunes) + private readonly IFortunesProvider fortunes; + public Fortune(IFortunesProvider fortunes) { this.fortunes = fortunes; } diff --git a/Geekbot.net/Program.cs b/Geekbot.net/Program.cs index 63cebad..51699e1 100755 --- a/Geekbot.net/Program.cs +++ b/Geekbot.net/Program.cs @@ -68,9 +68,11 @@ namespace Geekbot.net } services = new ServiceCollection(); - var fortunes = new Fortunes(); + var fortunes = new FortunesProvider(); + var checkEmImages = new CheckEmImageProvider(); var RandomClient = new Random(); - services.AddSingleton(fortunes); + services.AddSingleton(fortunes); + services.AddSingleton(checkEmImages); services.AddSingleton(RandomClient); services.AddSingleton(redis); diff --git a/Geekbot.net/Storage/checkEmPics b/Geekbot.net/Storage/checkEmPics new file mode 100644 index 0000000..03be23e --- /dev/null +++ b/Geekbot.net/Storage/checkEmPics @@ -0,0 +1,122 @@ +http://s19.postimg.org/pcq2kwzoj/4cb.png +http://s19.postimg.org/cvetk0f4z/5_Dim_Dy6p.jpg +http://s19.postimg.org/5hzfl1v37/1310151998600.jpg +http://s19.postimg.org/53y3lgazn/1324181141954.jpg +http://s19.postimg.org/724rjg3hf/1392512742365.png +http://s19.postimg.org/3rgejkdk3/1393501296733.png +http://s19.postimg.org/a6ffg8k9v/1401667341503.jpg +http://s19.postimg.org/qiph5yylf/1419231572452.jpg +http://s19.postimg.org/fqwi4m8ir/1427600681401.png +http://s19.postimg.org/4c00zzw6b/1447813628974.png +http://s19.postimg.org/uuio8puw3/b5_3q_ycaaavxtf.jpg +http://s19.postimg.org/bghu913fn/check_em_by_boyboy99100_d57xp3y.png +http://s19.postimg.org/s1pgooujn/l_Hkppjs.jpg +http://s19.postimg.org/m08itft0j/checkem.jpg +https://old.postimg.org/image/6vx33rb1b/ +https://old.postimg.org/image/wxiaz1mov/ +https://old.postimg.org/image/azqfizx27/ +https://old.postimg.org/image/6iy2kbiu7/ +https://old.postimg.org/image/k8slt45y7/ +https://old.postimg.org/image/t7ruxmplr/ +https://old.postimg.org/image/ssbzqvean/ +https://old.postimg.org/image/kbchfy9lr/ +https://old.postimg.org/image/dl0lk9btr/ +https://old.postimg.org/image/e5k80oufz/ +https://old.postimg.org/image/er005baqn/ +https://old.postimg.org/image/bfk2uzcin/ +https://old.postimg.org/image/556fp0jkv/ +https://old.postimg.org/image/i0efbryu7/ +https://old.postimg.org/image/943n7u87z/ +https://old.postimg.org/image/xn5op5cm7/ +https://old.postimg.org/image/3l5p4d0kf/ +https://old.postimg.org/image/5boq5ui3j/ +https://old.postimg.org/image/ru082bqcf/ +https://old.postimg.org/image/ytea1oqan/ +https://old.postimg.org/image/vu7dekgtb/ +https://old.postimg.org/image/hl7qwi2an/ +https://old.postimg.org/image/5aescfg9r/ +https://old.postimg.org/image/9gzmrrfvj/ +https://old.postimg.org/image/50bv6tr1b/ +https://old.postimg.org/image/afkl7silb/ +https://old.postimg.org/image/nrdsgzllr/ +https://old.postimg.org/image/s32e5zsin/ +https://old.postimg.org/image/5sej60v8f/ +https://old.postimg.org/image/lgfqctau7/ +https://old.postimg.org/image/tn7q4e0wv/ +https://old.postimg.org/image/8612arz1b/ +https://old.postimg.org/image/w5tf52mn3/ +https://old.postimg.org/image/zdxwi48wv/ +https://old.postimg.org/image/lphwghd0f/ +https://old.postimg.org/image/uzu0k0nq7/ +https://old.postimg.org/image/3vqzsxjbz/ +https://old.postimg.org/image/5d7uqqyov/ +https://old.postimg.org/image/dntnyku8v/ +https://old.postimg.org/image/dsxf891jz/ +https://old.postimg.org/image/3nyrioizj/ +https://old.postimg.org/image/6zx2bzaqn/ +https://old.postimg.org/image/wu6v1raqn/ +https://old.postimg.org/image/hb9f4n2fz/ +https://old.postimg.org/image/p7yhqm3a7/ +https://old.postimg.org/image/oelvxzx9b/ +https://old.postimg.org/image/vcq03xvdr/ +https://old.postimg.org/image/b08t1yqlb/ +https://old.postimg.org/image/6yrpwayan/ +https://old.postimg.org/image/btleukwm7/ +https://old.postimg.org/image/62ztuldzz/ +https://old.postimg.org/image/w3iq9pxr3/ +https://old.postimg.org/image/byp6493xb/ +https://old.postimg.org/image/xp2lf9xcv/ +https://old.postimg.org/image/j9p9u49pb/ +https://old.postimg.org/image/hvxmytafz/ +https://old.postimg.org/image/5eqzbnfa7/ +https://old.postimg.org/image/do2uq290f/ +https://old.postimg.org/image/54o261q1r/ +https://old.postimg.org/image/94qm4jr4v/ +https://old.postimg.org/image/lee88y0pr/ +https://old.postimg.org/image/bncb58cv3/ +https://old.postimg.org/image/5246j7me7/ +https://old.postimg.org/image/4uby8ym1r/ +https://old.postimg.org/image/qn996tj4v/ +https://old.postimg.org/image/c1dn4twyn/ +https://old.postimg.org/image/6rd9ra23j/ +https://lehcark14.files.wordpress.com/2008/08/botan16.jpg +http://i.imgur.com/p9vALew.jpg +http://i.imgur.com/4a9l2Rm.png +http://i.imgur.com/RNtixMQ.jpg +https://pbs.twimg.com/media/Cro9aIGUEAAkXCP.jpg +http://s16.postimg.org/empvloimd/Check_em_Guts.png +https://s18.postimg.io/qgbhe7u09/1424491645996.gif +http://s19.postimg.org/hhemlt7xf/3eb.jpg +http://s19.postimg.org/cwsg6vo83/8aa.png +http://s19.postimg.org/rh9j1pj6r/28mohl4.png +http://s19.postimg.org/zba4n3qzn/86d.jpg +http://s19.postimg.org/cb3hart5v/2016_09_16_08_58_45.png +http://s19.postimg.org/m9ofx92lf/bb1.jpg +http://s19.postimg.org/maydqo4f7/e8b.jpg +http://s19.postimg.org/yqzoy5n4z/fbe.png +http://s19.postimg.org/xd822unvn/giphy.gif +http://s19.postimg.org/c4udlf9er/l_TU3eup.jpg +https://66.media.tumblr.com/cc893a0ee40d73d083da3df4bdaf45cc/tumblr_mx8psiFduG1t1g1k8o1_500.gif +http://i.imgur.com/swbXHSy.gif +http://img1.reactor.cc/pics/post/full/Anime-Touhou-Project-Yakumo-Yukari-%D0%A0%D0%B5%D0%BA%D1%83%D1%80%D1%81%D0%B8%D1%8F-1303807.jpeg +http://i.imgur.com/ftGLHE0.png +http://i.imgur.com/JELDhKQ.png +http://imgur.com/yBJound +http://i.imgur.com/f7gAVPJ.png +http://i.imgur.com/HxWyo2Z.jpg +http://i.imgur.com/8Eb9CxQ.png +http://i.imgur.com/kOECcjz.png +http://i.imgur.com/MJLu7oJ.jpg +http://i.imgur.com/itG3rPM.jpg +http://i.imgur.com/G83Go9t.jpg +http://i.imgur.com/jI2dBnU.jpg +http://i.imgur.com/FtALzg0.jpg +http://i.imgur.com/GwZpJEv.gif +http://i.imgur.com/TYGRD3B.gif +http://i.imgur.com/P6TxLS3.png +http://i.imgur.com/phTVTdn.jpg +http://i.imgur.com/thhR6UE.jpg +http://i.imgur.com/KbROufx.jpg +http://i.imgur.com/sQqWbcm.jpg +http://i.imgur.com/YYpis53.png +http://i.imgur.com/kwaRd54.gif \ No newline at end of file diff --git a/Geekbot.net/fortunes b/Geekbot.net/Storage/fortunes similarity index 100% rename from Geekbot.net/fortunes rename to Geekbot.net/Storage/fortunes