feat(bot): implement 'all' filter
This commit is contained in:
parent
3feb464097
commit
540de53cd0
@ -12,7 +12,14 @@ function splitWords(filterValue: string): string[] {
|
||||
}
|
||||
|
||||
export const all = (filter: Filter, input: string) => {
|
||||
throw new Error("'all' filter not implemented");
|
||||
try {
|
||||
const flags = filter.is_insensitive ? "i" : "";
|
||||
return splitWords(filter.value)
|
||||
.every(word => new RegExp(String.raw`\b(${word})\b`, flags).test(input));
|
||||
} catch (error) {
|
||||
console.error(`ALL: Invalid regex pattern: ${filter.value}`, error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const any = (filter: Filter, input: string) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user