Skip to content
Snippets Groups Projects
Verified Commit d8e56a44 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixes #296

parent a85ab9e0
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -169,7 +169,7 @@ class IgnoreListManager constructor( ...@@ -169,7 +169,7 @@ class IgnoreListManager constructor(
val scope: ScopeType, val scope: ScopeType,
val scopeRule: String, val scopeRule: String,
val isActive: Boolean, val isActive: Boolean,
val regEx: Regex, val regEx: Regex?,
val scopeRegEx: Set<Regex> val scopeRegEx: Set<Regex>
) : Serializable { ) : Serializable {
constructor(type: Int, ignoreRule: String, isRegEx: Boolean, strictness: Int, scope: Int, constructor(type: Int, ignoreRule: String, isRegEx: Boolean, strictness: Int, scope: Int,
...@@ -181,13 +181,23 @@ class IgnoreListManager constructor( ...@@ -181,13 +181,23 @@ class IgnoreListManager constructor(
constructor(type: IgnoreType, ignoreRule: String, isRegEx: Boolean, strictness: StrictnessType, constructor(type: IgnoreType, ignoreRule: String, isRegEx: Boolean, strictness: StrictnessType,
scope: ScopeType, scopeRule: String, isActive: Boolean) : this( scope: ScopeType, scopeRule: String, isActive: Boolean) : this(
type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive, type, ignoreRule, isRegEx, strictness, scope, scopeRule, isActive,
try {
Regex(ignoreRule.let { Regex(ignoreRule.let {
if (isRegEx) it else GlobTransformer.convertGlobToRegex(it) if (isRegEx) it else GlobTransformer.convertGlobToRegex(it)
}, RegexOption.IGNORE_CASE), }, RegexOption.IGNORE_CASE)
} catch (_: Throwable) {
null
},
scopeRule.split(';') scopeRule.split(';')
.map(String::trim) .map(String::trim)
.map(GlobTransformer::convertGlobToRegex) .map(GlobTransformer::convertGlobToRegex)
.map { Regex(it, RegexOption.IGNORE_CASE) } .mapNotNull {
try {
Regex(it, RegexOption.IGNORE_CASE)
} catch (e: Throwable) {
null
}
}
.toSet() .toSet()
) )
...@@ -263,8 +273,8 @@ class IgnoreListManager constructor( ...@@ -263,8 +273,8 @@ class IgnoreListManager constructor(
it.scope == ScopeType.ChannelScope && it.scopeRegEx.any { it matches bufferName } it.scope == ScopeType.ChannelScope && it.scopeRegEx.any { it matches bufferName }
}.filter { }.filter {
val content = if (it.type == IgnoreType.MessageIgnore) msgContents else msgSender val content = if (it.type == IgnoreType.MessageIgnore) msgContents else msgSender
!it.isRegEx && it.regEx.matches(content) || !it.isRegEx && it.regEx?.matches(content) == true ||
it.isRegEx && it.regEx.containsMatchIn(content) it.isRegEx && it.regEx?.containsMatchIn(content) == true
}.map { }.map {
it.strictness it.strictness
}.sortedByDescending { }.sortedByDescending {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment