mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[entertainment] edit guess message instead of deleting and sending a new one
This commit is contained in:
@@ -35,11 +35,11 @@ public class Guess : CommonHandler
|
|||||||
{
|
{
|
||||||
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)
|
||||||
{
|
// {
|
||||||
await Reply($"Следующее использование через {cooldown - DateTime.Now:hh\\:mm\\:ss}.");
|
// await Reply($"Следующее использование через {cooldown - DateTime.Now:hh\\:mm\\:ss}.");
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary<int, GuessData>());
|
var guessDict = _guessCache.GetOr(Chat.Id, new ConcurrentDictionary<int, GuessData>());
|
||||||
|
|
||||||
@@ -114,7 +114,6 @@ public class Guess : CommonHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
await Bot.AnswerCallbackQueryAsync(CallbackQuery.Id);
|
await Bot.AnswerCallbackQueryAsync(CallbackQuery.Id);
|
||||||
await Bot.DeleteMessageAsync(Chat, (int) messageId);
|
|
||||||
|
|
||||||
guessDict.TryRemove((int) messageId, out _);
|
guessDict.TryRemove((int) messageId, out _);
|
||||||
_guessCache.SetValue(Chat.Id, guessDict, -1);
|
_guessCache.SetValue(Chat.Id, guessDict, -1);
|
||||||
@@ -133,7 +132,7 @@ public class Guess : CommonHandler
|
|||||||
message = $"{fromUser.ToHtml()} не угадал!";
|
message = $"{fromUser.ToHtml()} не угадал!";
|
||||||
}
|
}
|
||||||
|
|
||||||
await Bot.SendTextMessageAsync(Chat, message + postFix, parseMode: ParseMode.Html);
|
await Bot.EditMessageTextAsync(Chat, (int) messageId, message + postFix, parseMode: ParseMode.Html);
|
||||||
|
|
||||||
var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
|
var cooldownOption = await _db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "guessCooldown");
|
||||||
cooldownOption.SetValue(nextUse);
|
cooldownOption.SetValue(nextUse);
|
||||||
|
|||||||
Reference in New Issue
Block a user