.antispam will ignore image uploads with no message content

This commit is contained in:
Kwoth 2017-03-09 16:39:34 +01:00
parent 5f98c273d7
commit c1accaebfd

View File

@ -46,16 +46,18 @@ namespace NadekoBot.Modules.Administration
LastMessage = msg.ToUpperInvariant(); LastMessage = msg.ToUpperInvariant();
} }
public void ApplyNextMessage(string message) public void ApplyNextMessage(IUserMessage message)
{ {
var upperMsg = message.ToUpperInvariant(); var upperMsg = message.Content.ToUpperInvariant();
if (upperMsg == LastMessage) if (upperMsg != LastMessage || (string.IsNullOrWhiteSpace(upperMsg) && message.Attachments.Any()))
Count++;
else
{ {
LastMessage = upperMsg; LastMessage = upperMsg;
Count = 0; Count = 0;
} }
else
{
Count++;
}
} }
} }
@ -113,7 +115,7 @@ namespace NadekoBot.Modules.Administration
var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, new UserSpamStats(msg.Content), var stats = spamSettings.UserStats.AddOrUpdate(msg.Author.Id, new UserSpamStats(msg.Content),
(id, old) => (id, old) =>
{ {
old.ApplyNextMessage(msg.Content); return old; old.ApplyNextMessage(msg); return old;
}); });
if (stats.Count >= spamSettings.AntiSpamSettings.MessageThreshold) if (stats.Count >= spamSettings.AntiSpamSettings.MessageThreshold)