1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-11 23:39:36 +01:00

admit Filters with InlineQuery class

This commit is contained in:
َAhJ 2023-08-08 19:43:44 +03:30
parent b5f9a69d8b
commit d5093e2b6f
2 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ use Attribute;
use danog\MadelineProto\EventHandler; use danog\MadelineProto\EventHandler;
use danog\MadelineProto\EventHandler\AbstractMessage; use danog\MadelineProto\EventHandler\AbstractMessage;
use danog\MadelineProto\EventHandler\Query\ButtonQuery; use danog\MadelineProto\EventHandler\Query\ButtonQuery;
use danog\MadelineProto\EventHandler\InlineQuery;
use danog\MadelineProto\EventHandler\Update; use danog\MadelineProto\EventHandler\Update;
/** /**
@ -24,6 +25,7 @@ final class FilterFromAdmin extends Filter
public function apply(Update $update): bool public function apply(Update $update): bool
{ {
return ($update instanceof AbstractMessage && \in_array($update->senderId, $this->adminIds, true)) || 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));
} }
} }

View File

@ -5,6 +5,7 @@ namespace danog\MadelineProto\EventHandler\Filter;
use Attribute; use Attribute;
use danog\MadelineProto\EventHandler\Message; use danog\MadelineProto\EventHandler\Message;
use danog\MadelineProto\EventHandler\Query\ButtonQuery; use danog\MadelineProto\EventHandler\Query\ButtonQuery;
use danog\MadelineProto\EventHandler\InlineQuery;
use danog\MadelineProto\EventHandler\Update; use danog\MadelineProto\EventHandler\Update;
use Webmozart\Assert\Assert; use Webmozart\Assert\Assert;
@ -32,6 +33,11 @@ final class FilterRegex extends Filter
$update->matches = $matches; $update->matches = $matches;
return true; return true;
} }
if ($update instanceof InlineQuery && \preg_match($this->regex, $update->query, $matches)) {
/** @psalm-suppress InaccessibleProperty */
$update->matches = $matches;
return true;
}
return false; return false;
} }
} }