[entertainment] move cooldown check to the handler start in /guess

This commit is contained in:
Andriy
2023-01-18 02:20:37 +02:00
parent ec11cf4496
commit 9cbb5d7240
+2 -3
View File
@@ -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<int, GuessData>());
var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
var cooldown = cooldownOption.GetValue<DateTime>();
if (cooldown > DateTime.Now)
@@ -41,6 +38,8 @@ public class Guess : CommonHandler
return;
}
var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary<int, GuessData>());
var doesExist = guessDict.Any(pair => pair.Value.UserId == From.Id);
if (doesExist)
{