diff --git a/Core/Extensions/ChatExtension.cs b/Core/Extensions/ChatExtension.cs new file mode 100644 index 0000000..db1501c --- /dev/null +++ b/Core/Extensions/ChatExtension.cs @@ -0,0 +1,20 @@ +using System; +using Telegram.Bot.Types; +using Telegram.Bot.Types.Enums; + +namespace Kruzya.TelegramBot.Core.Extensions; + +public static class ChatExtension +{ + public static string ToLog(this Chat chat) + { + var title = chat.Type switch + { + ChatType.Private => $"{chat.FirstName} {chat.LastName}".Trim(), + _ => chat.Title + }; + + + return $"{title} (ID: {chat.Id}, Username: {chat.Username ?? "N/A"})"; + } +} \ No newline at end of file diff --git a/modules/Entertainment/Handler/Common.cs b/modules/Entertainment/Handler/Common.cs index b73da35..0b4eeab 100644 --- a/modules/Entertainment/Handler/Common.cs +++ b/modules/Entertainment/Handler/Common.cs @@ -33,7 +33,10 @@ namespace West.Entertainment.Handler { if (!_userService.IsUserSuper(From)) { - _logger.LogInformation("{User} attempted to call /cooldowns in \"{Chat}\"", From, Chat.Title); + _logger.LogWarning("{User} attempted to use super-user command /cooldowns in {Chat}", + From.ToLog(), + Chat.ToLog() + ); return; } diff --git a/modules/Entertainment/Handler/Roll.cs b/modules/Entertainment/Handler/Roll.cs index f9d93bd..cc4909f 100644 --- a/modules/Entertainment/Handler/Roll.cs +++ b/modules/Entertainment/Handler/Roll.cs @@ -43,7 +43,10 @@ public class Roll : CommonHandler { if (!_userService.IsUserSuper(From)) { - _logger.LogWarning("{user} attempted to use super-user command", From.ToLog()); + _logger.LogWarning("{User} attempted to use super-user command /reset_roll in {Chat}", + From.ToLog(), + Chat.ToLog() + ); return; } diff --git a/modules/Reputation/Handler/Reputation.cs b/modules/Reputation/Handler/Reputation.cs index 6260f1e..3d6f9fa 100644 --- a/modules/Reputation/Handler/Reputation.cs +++ b/modules/Reputation/Handler/Reputation.cs @@ -195,7 +195,10 @@ public class Reputation : CommonHandler { if (!_userService.IsUserSuper(From)) { - _logger.LogInformation("{User} attempted to modify someones reputation in {Chat}", From, Chat.Title); + _logger.LogWarning("{User} attempted to modify reputation in {Chat}", + From.ToLog(), + Chat.ToLog() + ); return false; }