From 7a1aa779329b4b49de55108752cbe7091427557e Mon Sep 17 00:00:00 2001 From: West14 <30056636+West14@users.noreply.github.com> Date: Tue, 8 Feb 2022 20:28:15 +0200 Subject: [PATCH] [entertainment] Add some debug. More correct permission check. --- .../Handler/Fun/AbstractAnimationReply.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs b/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs index e157dca..ce81450 100644 --- a/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs +++ b/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs @@ -43,7 +43,10 @@ namespace West.Entertainment.Handler.Fun protected async Task HandleSetAnimation() { var animation = Message?.ReplyToMessage?.Animation; - if (await CanPunish() || animation == null) return; + var isAdmin = await Bot.IsUserAdminAsync(Chat, From); + + _logger.LogDebug("IsAdmin: {IsAdmin}. FileId: {FileId}", isAdmin, animation?.FileId); + if (!isAdmin || animation == null) return; var animationFileOption = await GetAnimationFileOption(); animationFileOption.SetValue(animation.FileId); @@ -61,8 +64,13 @@ namespace West.Entertainment.Handler.Fun _logger.LogDebug("Animation: {Text}, ToLower: {ToLowerText}", Message!.Text, Message!.Text!.ToLower()); - - if (animationFileId.IsNullOrEmpty()) return false; + _logger.LogDebug("AnimationFileId: {FileId}", animationFileId); + + if (animationFileId.IsNullOrEmpty()) + { + _logger.LogDebug("AnimationFileId is empty. Ignoring."); + return false; + } var nextUseDt = nextUseOption.GetValue(); if (nextUseDt > DateTime.Now)