From fe6639a1e06867a5c588e59f56f5f458f5708a0e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 30 Jul 2018 20:24:55 +0200 Subject: [PATCH] Better handling of dadjokes --- DeukBot4/APIHandlers/CatPicHandler.cs | 2 +- DeukBot4/DeukBot4.csproj | 6 +++--- DeukBot4/MessageHandlers/MainHandler.cs | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/DeukBot4/APIHandlers/CatPicHandler.cs b/DeukBot4/APIHandlers/CatPicHandler.cs index aabe352..d092b38 100644 --- a/DeukBot4/APIHandlers/CatPicHandler.cs +++ b/DeukBot4/APIHandlers/CatPicHandler.cs @@ -8,7 +8,7 @@ using Discord; namespace DeukBot4.APIHandlers { - public class CatPicHandler + public static class CatPicHandler { private const string URL = "https://cataas.com"; diff --git a/DeukBot4/DeukBot4.csproj b/DeukBot4/DeukBot4.csproj index 19fbb2a..40a67b8 100644 --- a/DeukBot4/DeukBot4.csproj +++ b/DeukBot4/DeukBot4.csproj @@ -1,13 +1,13 @@  Exe - netcoreapp2.0 + netcoreapp2.1 7.1 - + - + \ No newline at end of file diff --git a/DeukBot4/MessageHandlers/MainHandler.cs b/DeukBot4/MessageHandlers/MainHandler.cs index b8e3b43..1480cbc 100644 --- a/DeukBot4/MessageHandlers/MainHandler.cs +++ b/DeukBot4/MessageHandlers/MainHandler.cs @@ -82,21 +82,32 @@ namespace DeukBot4.MessageHandlers if (!(message.Author is IGuildUser guildUser)) return; string newName; - var lower = message.Content.ToLowerInvariant(); + var content = message.Content; + var lower = content.ToLowerInvariant(); + if (lower.StartsWith("hi ")) + { + lower = lower.Remove(0, 3); + content = content.Remove(0, 3); + } + else if (lower.StartsWith("hello ")) + { + lower = lower.Remove(0, 6); + content = content.Remove(0, 6); + } if (lower[0] != 'i') return; if (lower.StartsWith("i'm ")) { - newName = message.Content.Remove(0, 4); + newName = content.Remove(0, 4); } else if (lower.StartsWith("im ")) { - newName = message.Content.Remove(0, 3); + newName = content.Remove(0, 3); } else if (lower.StartsWith("i am ")) { - newName = message.Content.Remove(0, 5); + newName = content.Remove(0, 5); } else {