mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-21 07:33:34 +00:00
replaced EvaluatorFilter with custom regex-based filter and removed non-dependency
This commit is contained in:
parent
abf7135e64
commit
a6b09faa84
3 changed files with 36 additions and 24 deletions
|
|
@ -0,0 +1,29 @@
|
|||
package net.psforever.filters;
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.filter.Filter;
|
||||
import ch.qos.logback.core.spi.FilterReply;
|
||||
|
||||
/**
|
||||
* Disrupts a variety of messages that, when formatted, match against the configured regular expression.
|
||||
* A replacement for the `EvaluatorFilter`.
|
||||
*/
|
||||
public class MsgRegexFilter extends Filter<ILoggingEvent> {
|
||||
private String regex;
|
||||
|
||||
@Override
|
||||
public FilterReply decide(ILoggingEvent event) {
|
||||
if (isStarted() && event.getFormattedMessage().matches(regex)) {
|
||||
return FilterReply.DENY;
|
||||
} else {
|
||||
return FilterReply.NEUTRAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.regex != null) {
|
||||
super.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue