mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-23 00:51:12 +01:00
fixing content
This commit is contained in:
parent
6ca86777a8
commit
8657940860
@ -16,12 +16,12 @@
|
||||
|
||||
namespace danog\MadelineProto\EventHandler\Filter;
|
||||
|
||||
use AssertionError;
|
||||
use Attribute;
|
||||
use danog\MadelineProto\EventHandler\CommandType;
|
||||
use AssertionError;
|
||||
use Webmozart\Assert\Assert;
|
||||
use danog\MadelineProto\EventHandler\Message;
|
||||
use danog\MadelineProto\EventHandler\Update;
|
||||
use Webmozart\Assert\Assert;
|
||||
use danog\MadelineProto\EventHandler\CommandType;
|
||||
|
||||
/**
|
||||
* Allow only messages containing the specified command.
|
||||
|
@ -17,10 +17,11 @@
|
||||
namespace danog\MadelineProto\EventHandler\Filter;
|
||||
|
||||
use Attribute;
|
||||
use danog\MadelineProto\EventHandler\Message;
|
||||
use danog\MadelineProto\EventHandler\Story\Story;
|
||||
use danog\MadelineProto\EventHandler\Update;
|
||||
use AssertionError;
|
||||
use Webmozart\Assert\Assert;
|
||||
use danog\MadelineProto\EventHandler\Update;
|
||||
use danog\MadelineProto\EventHandler\Message;
|
||||
use danog\MadelineProto\EventHandler\CommandType;
|
||||
|
||||
/**
|
||||
* Allow only messages containing the specified case-insensitive command.
|
||||
@ -29,15 +30,23 @@ use Webmozart\Assert\Assert;
|
||||
final class FilterCommandCaseInsensetive extends Filter
|
||||
{
|
||||
/**
|
||||
* @var array<CommandType>
|
||||
* @var list<CommandType>
|
||||
*/
|
||||
public readonly array $commandTypes;
|
||||
|
||||
/** Command */
|
||||
private readonly string $command;
|
||||
|
||||
/**
|
||||
* @param string $command Command
|
||||
* @param list<CommandType> $types Command types, if empty all command types are allowed.
|
||||
*/
|
||||
public function __construct(private readonly string $command, array $types = [CommandType::BANG, CommandType::DOT, CommandType::SLASH])
|
||||
{
|
||||
public function __construct(
|
||||
string $command,
|
||||
array $types = [CommandType::BANG, CommandType::DOT, CommandType::SLASH],
|
||||
private readonly ?string $encoding = null,
|
||||
) {
|
||||
$this->command = mb_strtolower($command, $encoding);
|
||||
Assert::true(preg_match("/^\w+$/", $command) === 1, "An invalid command was specified!");
|
||||
Assert::notEmpty($types, 'No command types were specified!');
|
||||
$c = [];
|
||||
|
@ -28,11 +28,14 @@ use Webmozart\Assert\Assert;
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
final class FilterTextCaseInsensitive extends Filter
|
||||
{
|
||||
private readonly string $content;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $content,
|
||||
string $content,
|
||||
private readonly ?string $encoding = null,
|
||||
) {
|
||||
Assert::notEmpty($content);
|
||||
$this->content = mb_strtolower($content, $encoding);
|
||||
}
|
||||
|
||||
public function apply(Update $update): bool
|
||||
|
@ -28,11 +28,14 @@ use Webmozart\Assert\Assert;
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
final class FilterTextContainsCaseInsensitive extends Filter
|
||||
{
|
||||
private readonly string $content;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $content,
|
||||
string $content,
|
||||
private readonly ?string $encoding = null,
|
||||
) {
|
||||
Assert::notEmpty($content);
|
||||
$this->content = mb_strtolower($content, $encoding);
|
||||
}
|
||||
public function apply(Update $update): bool
|
||||
{
|
||||
|
@ -28,11 +28,14 @@ use Webmozart\Assert\Assert;
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
final class FilterTextEndsCaseInsensitive extends Filter
|
||||
{
|
||||
private readonly string $content;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $content,
|
||||
string $content,
|
||||
private readonly ?string $encoding = null,
|
||||
) {
|
||||
Assert::notEmpty($content);
|
||||
$this->content = mb_strtolower($content, $encoding);
|
||||
}
|
||||
|
||||
public function apply(Update $update): bool
|
||||
|
@ -28,11 +28,14 @@ use Webmozart\Assert\Assert;
|
||||
#[Attribute(Attribute::TARGET_METHOD)]
|
||||
final class FilterTextStartsCaseInsensitive extends Filter
|
||||
{
|
||||
private readonly string $content;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $content,
|
||||
string $content,
|
||||
private readonly ?string $encoding = null,
|
||||
) {
|
||||
Assert::notEmpty($content);
|
||||
$this->content = mb_strtolower($content, $encoding);
|
||||
}
|
||||
|
||||
public function apply(Update $update): bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user