mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[entertainment] add /reset_roll command
This commit is contained in:
@@ -2,16 +2,20 @@
|
||||
using BotFramework.Enums;
|
||||
using System.Threading.Tasks;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Kruzya.TelegramBot.Core;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Kruzya.TelegramBot.Core.Service;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace West.Entertainment.Handler;
|
||||
|
||||
public class Roll : CommonHandler
|
||||
{
|
||||
private readonly ILogger<Roll> _logger;
|
||||
private readonly IReputation _reputation;
|
||||
private readonly UserService _userService;
|
||||
|
||||
[Command(InChat.Public, "roll", CommandParseMode.Both)]
|
||||
public async Task HandleRoll()
|
||||
@@ -34,8 +38,28 @@ public class Roll : CommonHandler
|
||||
Db.AddOrUpdate(cdOption);
|
||||
}
|
||||
|
||||
public Roll(CoreContext db, IReputation reputation) : base(db)
|
||||
[Command(InChat.Public, "reset_roll", CommandParseMode.Both)]
|
||||
public async Task HandleResetRoll()
|
||||
{
|
||||
if (!_userService.IsUserSuper(From))
|
||||
{
|
||||
_logger.LogWarning("{user} attempted to use super-user command", From.ToLog());
|
||||
return;
|
||||
}
|
||||
|
||||
var cooldownList = Db.UserValues
|
||||
.Where(q => q.BotUser.ChatId == Chat.Id && q.Name == "rollNextUse");
|
||||
|
||||
Db.UserValues.RemoveRange(cooldownList);
|
||||
await Db.SaveChangesAsync();
|
||||
|
||||
await Reply($"Кулдаун /roll сброшен для чата \"{Chat.Title}\".");
|
||||
}
|
||||
|
||||
public Roll(CoreContext db, IReputation reputation, UserService userService, ILogger<Roll> logger) : base(db)
|
||||
{
|
||||
_reputation = reputation;
|
||||
_userService = userService;
|
||||
_logger = logger;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user