mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Add filters.PAID_MEDIA
(#4357)
This commit is contained in:
parent
dba7866aab
commit
52237cf00c
2 changed files with 20 additions and 0 deletions
|
@ -58,6 +58,7 @@ __all__ = (
|
|||
"IS_FROM_OFFLINE",
|
||||
"IS_TOPIC_MESSAGE",
|
||||
"LOCATION",
|
||||
"PAID_MEDIA",
|
||||
"PASSPORT_DATA",
|
||||
"PHOTO",
|
||||
"POLL",
|
||||
|
@ -1706,6 +1707,20 @@ class Mention(MessageFilter):
|
|||
return any(self._check_mention(message, mention) for mention in self._mentions)
|
||||
|
||||
|
||||
class _PaidMedia(MessageFilter):
|
||||
__slots__ = ()
|
||||
|
||||
def filter(self, message: Message) -> bool:
|
||||
return bool(message.paid_media)
|
||||
|
||||
|
||||
PAID_MEDIA = _PaidMedia(name="filters.PAID_MEDIA")
|
||||
"""Messages that contain :attr:`telegram.Message.paid_media`.
|
||||
|
||||
.. versionadded:: NEXT.VERSION
|
||||
"""
|
||||
|
||||
|
||||
class _PassportData(MessageFilter):
|
||||
__slots__ = ()
|
||||
|
||||
|
|
|
@ -902,6 +902,11 @@ class TestFilters:
|
|||
update.message.story = "test"
|
||||
assert filters.STORY.check_update(update)
|
||||
|
||||
def test_filters_paid_media(self, update):
|
||||
assert not filters.PAID_MEDIA.check_update(update)
|
||||
update.message.paid_media = "test"
|
||||
assert filters.PAID_MEDIA.check_update(update)
|
||||
|
||||
def test_filters_video(self, update):
|
||||
assert not filters.VIDEO.check_update(update)
|
||||
update.message.video = "test"
|
||||
|
|
Loading…
Reference in a new issue