From d5093e2b6f54d9fc70f650a1f12de25965cf143b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=8EAhJ?= Date: Tue, 8 Aug 2023 19:43:44 +0330 Subject: [PATCH] admit Filters with InlineQuery class --- src/EventHandler/Filter/FilterFromAdmin.php | 4 +++- src/EventHandler/Filter/FilterRegex.php | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/EventHandler/Filter/FilterFromAdmin.php b/src/EventHandler/Filter/FilterFromAdmin.php index c1edbe3f7..2d75485bd 100644 --- a/src/EventHandler/Filter/FilterFromAdmin.php +++ b/src/EventHandler/Filter/FilterFromAdmin.php @@ -6,6 +6,7 @@ use Attribute; use danog\MadelineProto\EventHandler; use danog\MadelineProto\EventHandler\AbstractMessage; use danog\MadelineProto\EventHandler\Query\ButtonQuery; +use danog\MadelineProto\EventHandler\InlineQuery; use danog\MadelineProto\EventHandler\Update; /** @@ -24,6 +25,7 @@ final class FilterFromAdmin extends Filter public function apply(Update $update): bool { return ($update instanceof AbstractMessage && \in_array($update->senderId, $this->adminIds, true)) || - ($update instanceof ButtonQuery && \in_array($update->userId, $this->adminIds, true)); + ($update instanceof ButtonQuery && \in_array($update->userId, $this->adminIds, true)) || + ($update instanceof InlineQuery && \in_array($update->userId, $this->adminIds, true)); } } diff --git a/src/EventHandler/Filter/FilterRegex.php b/src/EventHandler/Filter/FilterRegex.php index a7ca76148..c285643ac 100644 --- a/src/EventHandler/Filter/FilterRegex.php +++ b/src/EventHandler/Filter/FilterRegex.php @@ -5,6 +5,7 @@ namespace danog\MadelineProto\EventHandler\Filter; use Attribute; use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\Query\ButtonQuery; +use danog\MadelineProto\EventHandler\InlineQuery; use danog\MadelineProto\EventHandler\Update; use Webmozart\Assert\Assert; @@ -32,6 +33,11 @@ final class FilterRegex extends Filter $update->matches = $matches; return true; } + if ($update instanceof InlineQuery && \preg_match($this->regex, $update->query, $matches)) { + /** @psalm-suppress InaccessibleProperty */ + $update->matches = $matches; + return true; + } return false; } }