From 948c48909e5b1395451ca85bdef07e3937c3de88 Mon Sep 17 00:00:00 2001 From: runebaas Date: Sun, 22 Jul 2018 15:02:53 +0200 Subject: [PATCH] Allow the same guess after 24h again with !roll --- Geekbot.net/Commands/Games/Roll.cs | 15 +++++++++------ Geekbot.net/Lib/Localization/Translations.json | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Geekbot.net/Commands/Games/Roll.cs b/Geekbot.net/Commands/Games/Roll.cs index 30697df..e8a89c0 100644 --- a/Geekbot.net/Commands/Games/Roll.cs +++ b/Geekbot.net/Commands/Games/Roll.cs @@ -34,15 +34,18 @@ namespace Geekbot.net.Commands.Games var transDict = _translation.GetDict(Context); if (guess <= 100 && guess > 0) { - var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious", Context.Message.Author.Id); - if (!prevRoll.IsNullOrEmpty && prevRoll.ToString() == guess.ToString()) + var prevRoll = _redis.HashGet($"{Context.Guild.Id}:RollsPrevious2", Context.Message.Author.Id).ToString()?.Split('|'); + if (prevRoll?.Length == 2) { - await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention)); - return; + if (prevRoll[0] == guess.ToString() && DateTime.Parse(prevRoll[1]) > DateTime.Now.AddDays(-1)) + { + await ReplyAsync(string.Format(transDict["NoPrevGuess"], Context.Message.Author.Mention)); + return; + } } - _redis.HashSet($"{Context.Guild.Id}:RollsPrevious", - new[] {new HashEntry(Context.Message.Author.Id, guess)}); + _redis.HashSet($"{Context.Guild.Id}:RollsPrevious2", + new[] {new HashEntry(Context.Message.Author.Id, $"{guess}|{DateTime.Now}")}); await ReplyAsync(string.Format(transDict["Rolled"], Context.Message.Author.Mention, number, guess)); if (guess == number) { diff --git a/Geekbot.net/Lib/Localization/Translations.json b/Geekbot.net/Lib/Localization/Translations.json index 2d3414e..fab8b94 100644 --- a/Geekbot.net/Lib/Localization/Translations.json +++ b/Geekbot.net/Lib/Localization/Translations.json @@ -93,8 +93,8 @@ "CHDE": "{0}, du hesch {1} grollt" }, "NoPrevGuess": { - "EN": ":red_circle: {0}, you can't guess the same number again", - "CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate" + "EN": ":red_circle: {0}, you can't guess the same number again within 24 hours", + "CHDE": ":red_circle: {0}, du chasch nid nomol es gliche rate innerhalb vo 24 stund" } } } \ No newline at end of file