diff --git a/modules/Entertainment/Roll.cs b/modules/Entertainment/Roll.cs new file mode 100644 index 0000000..40bdd93 --- /dev/null +++ b/modules/Entertainment/Roll.cs @@ -0,0 +1,41 @@ +using BotFramework.Attributes; +using BotFramework.Enums; +using System.Threading.Tasks; +using System; +using Kruzya.TelegramBot.Core; +using Kruzya.TelegramBot.Core.Data; +using Kruzya.TelegramBot.Core.Extensions; +using Kruzya.TelegramBot.Core.Service; + +namespace West.Entertainment; + +public class Roll : CommonHandler +{ + private readonly IReputation _reputation; + + [Command(InChat.Public, "roll", CommandParseMode.Both)] + public async Task HandleRoll() + { + var cdOption = await Db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "rollNextUse"); + var cd = cdOption.GetValue(); + + if (cd > DateTime.Now) + { + await Reply($"Следующее использование через {cd - DateTime.Now:hh\\:mm\\:ss}."); + return; + } + + var newRep = new Random().Next(0, 50); + + await Reply($"Вы получили {newRep} кармы."); + await _reputation.IncrementReputationAsync(Chat, From, newRep); + + cdOption.SetValue(DateTime.Now.AddHours(1)); + Db.AddOrUpdate(cdOption); + } + + public Roll(CoreContext db, IReputation reputation) : base(db) + { + _reputation = reputation; + } +} \ No newline at end of file diff --git a/modules/Reputation/Handler/Reputation.cs b/modules/Reputation/Handler/Reputation.cs index 0d8a08a..6260f1e 100644 --- a/modules/Reputation/Handler/Reputation.cs +++ b/modules/Reputation/Handler/Reputation.cs @@ -179,28 +179,7 @@ public class Reputation : CommonHandler await Bot.SendTextMessageAsync(Chat!, msg.ToString(), ParseMode.Html, disableNotification: true); } - - [Command(InChat.Public, "roll", CommandParseMode.Both)] - public async Task HandleRoll() - { - var cdOption = await Db.UserValues.FindOrCreateOption(Chat.Id, From.Id, "rollNextUse"); - var cd = cdOption.GetValue(); - - if(cd > DateTime.Now) - { - await Reply("Ты уже крутил!"); - return; - } - - int new_rep = new Random().Next(-50, 51); - - await Reply($"Вы выиграли {new_rep} кармы на сиськи!"); - //await _reputationService.IncrementReputationAsync(Chat, From, new_rep); - - cdOption.SetValue(DateTime.Now.AddDays(1)); - Db.AddOrUpdate(cdOption); - } - + private async Task SendReputationModifyResponse(double reputation) { await Reply(