-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8e8b09
commit 8e7502e
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Mateodioev\TgHandler\Filters; | ||
|
||
use Attribute; | ||
use Mateodioev\Bots\Telegram\Types\abstractType; | ||
use Mateodioev\TgHandler\Context; | ||
|
||
#[Attribute] | ||
class FilterMessageMedia implements Filter | ||
{ | ||
public function __construct( | ||
private readonly MediaType $mediaType | ||
) { | ||
} | ||
|
||
public function apply(Context $ctx): bool | ||
{ | ||
return $ctx->{$this->mediaType->name} !== abstractType::DEFAULT_PARAM; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Mateodioev\TgHandler\Filters; | ||
|
||
use Attribute; | ||
use Mateodioev\TgHandler\Context; | ||
|
||
#[Attribute] | ||
class FilterMessageSticker implements Filter | ||
{ | ||
private Filter $filter; | ||
|
||
public function __construct() | ||
{ | ||
$this->filter = new FilterMessageMedia(MediaType::sticker); | ||
} | ||
|
||
public function apply(Context $ctx): bool | ||
{ | ||
return $this->filter->apply($ctx); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Mateodioev\TgHandler\Filters; | ||
|
||
enum MediaType | ||
{ | ||
case animation; | ||
case audio; | ||
case document; | ||
case photo; | ||
case sticker; | ||
case story; | ||
case video; | ||
case video_note; | ||
case voice; | ||
} |