From 712baf0c07b76ca3ee3aabf6e743a287217a79bc Mon Sep 17 00:00:00 2001 From: Or Bin Date: Sat, 14 Apr 2018 22:53:54 +0300 Subject: [PATCH] Added video note filter (#1067) --- AUTHORS.rst | 1 + telegram/ext/filters.py | 9 +++++++++ tests/test_filters.py | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index 13c10c1f5..48ae3efcc 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -53,6 +53,7 @@ The following wonderful people contributed directly or indirectly to this projec - `Noam Meltzer `_ - `Oleg Shlyazhko `_ - `Oleg Sushchenko `_ +- `Or Bin `_ - `overquota `_ - `Patrick Hofmann `_ - `Paul Larsen `_ diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 6a6e4cdfb..3539914eb 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -336,6 +336,15 @@ class Filters(object): voice = _Voice() """:obj:`Filter`: Messages that contain :class:`telegram.Voice`.""" + class _VideoNote(BaseFilter): + name = 'Filters.video_note' + + def filter(self, message): + return bool(message.video_note) + + video_note = _VideoNote() + """:obj:`Filter`: Messages that contain :class:`telegram.VideoNote`.""" + class _Contact(BaseFilter): name = 'Filters.contact' diff --git a/tests/test_filters.py b/tests/test_filters.py index 74ea941e7..f6be41045 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -205,6 +205,11 @@ class TestFilters(object): message.voice = 'test' assert Filters.voice(message) + def test_filters_video_note(self, message): + assert not Filters.video_note(message) + message.video_note = 'test' + assert Filters.video_note(message) + def test_filters_contact(self, message): assert not Filters.contact(message) message.contact = 'test'