mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 21:35:13 +00:00
Add the ability to filter by user-agent
This commit is contained in:
parent
40114c6045
commit
645f5d0a0a
1 changed files with 6 additions and 0 deletions
|
@ -74,9 +74,12 @@ class MessageFilter
|
|||
return false;
|
||||
}
|
||||
} elseif (str_starts_with($word, '?')) {
|
||||
$item['ua'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
if (self::test_condition(substr($word, 1), $item)) {
|
||||
unset($item['ua']);
|
||||
return false;
|
||||
}
|
||||
unset($item['ua']);
|
||||
} elseif ((str_starts_with($word, '/')) && preg_match($word, $item['body'])) {
|
||||
return false;
|
||||
} elseif (stristr($item['body'], $word) !== false) {
|
||||
|
@ -127,9 +130,12 @@ class MessageFilter
|
|||
}
|
||||
} elseif (str_starts_with($word, '?')) {
|
||||
// ?item match
|
||||
$item['ua'] = $_SERVER['HTTP_USER_AGENT'] ?? '';
|
||||
if (self::test_condition(substr($word, 1), $item)) {
|
||||
unset($item['ua']);
|
||||
return true;
|
||||
}
|
||||
unset($item['ua']);
|
||||
} elseif ((str_starts_with($word, '/')) && preg_match($word, $text)) {
|
||||
// /regular expression match/
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue