From bc0da6e8c2ef3de6d63c6ead45f3baf274419138 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Fri, 4 Mar 2016 17:55:13 +0100 Subject: [PATCH] externalized pats/cries --- NadekoBot/Classes/JSONModels/Configuration.cs | 18 +++++++++++ NadekoBot/Commands/CopyCommand.cs | 1 + NadekoBot/Modules/Conversations.cs | 32 +++++++++---------- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/NadekoBot/Classes/JSONModels/Configuration.cs b/NadekoBot/Classes/JSONModels/Configuration.cs index d6ce3fdd..9b2efb60 100644 --- a/NadekoBot/Classes/JSONModels/Configuration.cs +++ b/NadekoBot/Classes/JSONModels/Configuration.cs @@ -12,5 +12,23 @@ namespace NadekoBot.Classes.JSONModels { 119174277298782216, 143515953525817344 }; + public string[] CryResponses = { + "http://i.imgur.com/Xg3i1Qy.gif", + "http://i.imgur.com/3K8DRrU.gif", + "http://i.imgur.com/k58BcAv.gif", + "http://i.imgur.com/I2fLXwo.gif" + }; + + public string[] PatResponses = { + "http://i.imgur.com/IiQwK12.gif", + "http://i.imgur.com/JCXj8yD.gif", + "http://i.imgur.com/qqBl2bm.gif", + "http://i.imgur.com/eOJlnwP.gif", + "https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif", + "https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif", + "https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif", + "http://gallery1.anivide.com/_full/65030_1382582341.gif", + "https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ", + }; } } diff --git a/NadekoBot/Commands/CopyCommand.cs b/NadekoBot/Commands/CopyCommand.cs index 351d5449..35ce53f2 100644 --- a/NadekoBot/Commands/CopyCommand.cs +++ b/NadekoBot/Commands/CopyCommand.cs @@ -39,6 +39,7 @@ namespace NadekoBot.Commands cgb.CreateCommand("copyme") .Alias("cm") .Description("Nadeko starts copying everything you say. Disable with cs") + .Parameter("silent") .Do(DoFunc()); cgb.CreateCommand("cs") diff --git a/NadekoBot/Modules/Conversations.cs b/NadekoBot/Modules/Conversations.cs index bc261675..066ce3b7 100644 --- a/NadekoBot/Modules/Conversations.cs +++ b/NadekoBot/Modules/Conversations.cs @@ -177,27 +177,25 @@ namespace NadekoBot.Modules { .Do(async e => { var user = e.GetArg("user"); if (string.IsNullOrWhiteSpace(user) || !e.Message.MentionedUsers.Any()) return; - string[] pats = { "http://i.imgur.com/IiQwK12.gif", - "http://i.imgur.com/JCXj8yD.gif", - "http://i.imgur.com/qqBl2bm.gif", - "http://i.imgur.com/eOJlnwP.gif", - "https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif", - "https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif", - "https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif", - "http://gallery1.anivide.com/_full/65030_1382582341.gif", - "https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ", - }; - await e.Channel.SendMessage($"{e.Message.MentionedUsers.First().Mention} {pats[rng.Next(0, pats.Length)]}"); + try { + await e.Channel.SendMessage( + $"{e.Message.MentionedUsers.First().Mention} " + + $"{NadekoBot.Config.PatResponses[rng.Next(0, NadekoBot.Config.PatResponses.Length)]}"); + } catch { + await e.Channel.SendMessage("Error while handling PatResponses check your data/config.json"); + } }); cgb.CreateCommand("cry") .Description("Tell Nadeko to cry. You are a heartless monster if you use this command.") .Do(async e => { - string[] pats = { "http://i.imgur.com/Xg3i1Qy.gif", - "http://i.imgur.com/3K8DRrU.gif", - "http://i.imgur.com/k58BcAv.gif", - "http://i.imgur.com/I2fLXwo.gif" }; - await e.Channel.SendMessage($"(•̥́ _•ૅ。)\n{pats[rng.Next(0, pats.Length)]}"); + try { + await + e.Channel.SendMessage( + $"(•̥́ _•ૅ。)\n{NadekoBot.Config.CryResponses[rng.Next(0, NadekoBot.Config.CryResponses.Length)]}"); + } catch { + await e.Channel.SendMessage("Error while handling CryResponses check your data/config.json"); + } }); cgb.CreateCommand("are you real") @@ -277,7 +275,7 @@ namespace NadekoBot.Modules { var msgs = (await e.Channel.DownloadMessages(100)) .Where(m => m.MentionedUsers.Contains(e.User)) .OrderByDescending(m => m.Timestamp); - if (msgs.Count() > 0) + if (msgs.Any()) msg = msgs.First(); else { var attempt = 0;