From c1accaebfd1c555bd8da9b8438a302440eb0b4ce Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 9 Mar 2017 16:39:34 +0100 Subject: [PATCH] .antispam will ignore image uploads with no message content --- .../Administration/Commands/ProtectionCommands.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Commands/ProtectionCommands.cs b/src/NadekoBot/Modules/Administration/Commands/ProtectionCommands.cs index 8e2bd691..af7269c9 100644 --- a/src/NadekoBot/Modules/Administration/Commands/ProtectionCommands.cs +++ b/src/NadekoBot/Modules/Administration/Commands/ProtectionCommands.cs @@ -46,16 +46,18 @@ namespace NadekoBot.Modules.Administration LastMessage = msg.ToUpperInvariant(); } - public void ApplyNextMessage(string message) + public void ApplyNextMessage(IUserMessage message) { - var upperMsg = message.ToUpperInvariant(); - if (upperMsg == LastMessage) - Count++; - else + var upperMsg = message.Content.ToUpperInvariant(); + if (upperMsg != LastMessage || (string.IsNullOrWhiteSpace(upperMsg) && message.Attachments.Any())) { LastMessage = upperMsg; Count = 0; } + else + { + Count++; + } } } @@ -113,7 +115,7 @@ namespace NadekoBot.Modules.Administration var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, new UserSpamStats(msg.Content), (id, old) => { - old.ApplyNextMessage(msg.Content); return old; + old.ApplyNextMessage(msg); return old; }); if (stats.Count >= spamSettings.AntiSpamSettings.MessageThreshold)