From 9cbb5d7240e7444df8bf35e8d6671f3f86aaa36b Mon Sep 17 00:00:00 2001 From: Andriy <30056636+West14@users.noreply.github.com> Date: Wed, 18 Jan 2023 02:20:37 +0200 Subject: [PATCH] [entertainment] move cooldown check to the handler start in /guess --- modules/Entertainment/Handler/Guess.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/Entertainment/Handler/Guess.cs b/modules/Entertainment/Handler/Guess.cs index fbef62f..b4726ca 100644 --- a/modules/Entertainment/Handler/Guess.cs +++ b/modules/Entertainment/Handler/Guess.cs @@ -2,7 +2,6 @@ using System.Collections.Concurrent; using System.Linq; using System.Threading.Tasks; -using BotFramework; using BotFramework.Attributes; using BotFramework.Enums; using Kruzya.TelegramBot.Core; @@ -31,8 +30,6 @@ public class Guess : CommonHandler [Command(InChat.Public, "guess", CommandParseMode.Both)] public async Task HandleGuess() { - var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary()); - var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown"); var cooldown = cooldownOption.GetValue(); if (cooldown > DateTime.Now) @@ -41,6 +38,8 @@ public class Guess : CommonHandler return; } + var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary()); + var doesExist = guessDict.Any(pair => pair.Value.UserId == From.Id); if (doesExist) {