From c82d6ec6668d22480869d0988c1527807c1daff2 Mon Sep 17 00:00:00 2001 From: Runebaas Date: Fri, 15 Sep 2017 21:10:22 +0200 Subject: [PATCH] Add Dub, Trips and Quads check to !checkem (please fix if you see this) --- Geekbot.net/Modules/CheckEm.cs | 60 ++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/Geekbot.net/Modules/CheckEm.cs b/Geekbot.net/Modules/CheckEm.cs index 6c5d45f..150b97d 100644 --- a/Geekbot.net/Modules/CheckEm.cs +++ b/Geekbot.net/Modules/CheckEm.cs @@ -19,20 +19,54 @@ namespace Geekbot.net.Modules [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); + try + { + int number = rnd.Next(10000000, 99999999); + var dubtriqua = ""; + + var ns = GetIntArray(number); + Console.WriteLine(ns.Length); + if (ns[7] == ns[6]) + { + dubtriqua = "DUBS"; + if (ns[6] == ns[5]) + { + dubtriqua = "TRIPS"; + if (ns[5] == ns[4]) + { + dubtriqua = "QUADS"; + } + } + } + + var sb = new StringBuilder(); + sb.AppendLine($"Check em {Context.User.Mention}"); + sb.AppendLine($"**{number}**"); + if (!string.IsNullOrEmpty(dubtriqua)) + { + sb.AppendLine($":tada: {dubtriqua} :tada:"); + } + sb.AppendLine(checkEmImages.GetRandomCheckEmPic()); + + await ReplyAsync(sb.ToString()); + } + catch (Exception e) + { + Console.WriteLine(e.Message); } + + } + + private int[] GetIntArray(int num) + { + List listOfInts = new List(); + while (num > 0) + { + listOfInts.Add(num % 10); + num = num / 10; + } + listOfInts.Reverse(); + return listOfInts.ToArray(); } } } \ No newline at end of file