bool DetectChatSpam() { if (this == Console) { return(false); } if (spamChatLog.Count >= SpamChatCount) { DateTime oldestTime = spamChatLog.Dequeue(); if (DateTime.UtcNow.Subtract(oldestTime).TotalSeconds < SpamChatTimer) { muteWarnings++; if (muteWarnings > ConfigKey.AntispamMaxWarnings.GetInt()) { Session.KickNow("You were kicked for repeated spamming.", LeaveReason.MessageSpamKick); Server.SendToAll("&W{0} was kicked for repeated spamming.", GetClassyName()); } else { Info.Mute("(antispam)", AutoMuteDuration); Message("You have been muted for {0} seconds. Slow down.", AutoMuteDuration.TotalSeconds); } return(true); } } spamChatLog.Enqueue(DateTime.UtcNow); return(false); }
bool CheckChatSpam() { if (spamChatLog.Count >= spamChatCount) { DateTime oldestTime = spamChatLog.Dequeue(); if (DateTime.Now.Subtract(oldestTime).TotalSeconds < spamChatTimer) { muteWarnings++; if (muteWarnings > world.config.GetInt("AntispamMaxWarnings")) { session.KickNow("You were kicked for repeated spamming."); world.SendToAll(Color.Red + name + " was kicked for suspected spamming.", null); } else { mutedUntil = DateTime.Now.Add(muteDuration); Message("You have been muted for " + muteDuration.TotalSeconds + " seconds. Slow down."); } return(true); } } spamChatLog.Enqueue(DateTime.Now); return(false); }