mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[entertainment] move cooldown check to the handler start in /guess
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BotFramework;
|
|
||||||
using BotFramework.Attributes;
|
using BotFramework.Attributes;
|
||||||
using BotFramework.Enums;
|
using BotFramework.Enums;
|
||||||
using Kruzya.TelegramBot.Core;
|
using Kruzya.TelegramBot.Core;
|
||||||
@@ -31,8 +30,6 @@ public class Guess : CommonHandler
|
|||||||
[Command(InChat.Public, "guess", CommandParseMode.Both)]
|
[Command(InChat.Public, "guess", CommandParseMode.Both)]
|
||||||
public async Task HandleGuess()
|
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 cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
|
||||||
var cooldown = cooldownOption.GetValue<DateTime>();
|
var cooldown = cooldownOption.GetValue<DateTime>();
|
||||||
if (cooldown > DateTime.Now)
|
if (cooldown > DateTime.Now)
|
||||||
@@ -41,6 +38,8 @@ public class Guess : CommonHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary<int, GuessData>());
|
||||||
|
|
||||||
var doesExist = guessDict.Any(pair => pair.Value.UserId == From.Id);
|
var doesExist = guessDict.Any(pair => pair.Value.UserId == From.Id);
|
||||||
if (doesExist)
|
if (doesExist)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user