Skip to content

Commit 712baf0

Browse files
OrBinjh0ker
authored andcommitted
Added video note filter (python-telegram-bot#1067)
1 parent 59659ea commit 712baf0

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following wonderful people contributed directly or indirectly to this projec
5353
- `Noam Meltzer <https://github.com/tsnoam>`_
5454
- `Oleg Shlyazhko <https://github.com/ollmer>`_
5555
- `Oleg Sushchenko <https://github.com/feuillemorte>`_
56+
- `Or Bin <https://github.com/OrBin>`_
5657
- `overquota <https://github.com/overquota>`_
5758
- `Patrick Hofmann <https://github.com/PH89>`_
5859
- `Paul Larsen <https://github.com/PaulSonOfLars>`_

telegram/ext/filters.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,15 @@ def filter(self, message):
336336
voice = _Voice()
337337
""":obj:`Filter`: Messages that contain :class:`telegram.Voice`."""
338338

339+
class _VideoNote(BaseFilter):
340+
name = 'Filters.video_note'
341+
342+
def filter(self, message):
343+
return bool(message.video_note)
344+
345+
video_note = _VideoNote()
346+
""":obj:`Filter`: Messages that contain :class:`telegram.VideoNote`."""
347+
339348
class _Contact(BaseFilter):
340349
name = 'Filters.contact'
341350

tests/test_filters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ def test_filters_voice(self, message):
205205
message.voice = 'test'
206206
assert Filters.voice(message)
207207

208+
def test_filters_video_note(self, message):
209+
assert not Filters.video_note(message)
210+
message.video_note = 'test'
211+
assert Filters.video_note(message)
212+
208213
def test_filters_contact(self, message):
209214
assert not Filters.contact(message)
210215
message.contact = 'test'

0 commit comments

Comments
 (0)