diff --git a/AUTHORS.rst b/AUTHORS.rst index 63cd5e0bdb5..62de900d412 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -26,6 +26,7 @@ The following wonderful people contributed directly or indirectly to this projec - `d-qoi `_ - `daimajia `_ - `Daniel Reed `_ +- `Eana Hufwe `_ - `Ehsan Online `_ - `Eli Gao `_ - `Emilio Molinari `_ diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 8e4eac8012a..1f74e3a32ec 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -956,6 +956,15 @@ def filter(self, message): passport_data = _PassportData() """Messages that contain a :class:`telegram.PassportData`""" + class _Poll(BaseFilter): + name = 'Filters.poll' + + def filter(self, message): + return bool(message.poll) + + poll = _Poll() + """Messages that contain a :class:`telegram.Poll`.""" + class language(BaseFilter): """Filters messages to only allow those which are from users with a certain language code. diff --git a/tests/test_filters.py b/tests/test_filters.py index b1525b87e4a..a48ba2d5596 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -599,6 +599,11 @@ def test_filters_passport_data(self, update): update.message.passport_data = 'test' assert Filters.passport_data(update) + def test_filters_poll(self, update): + assert not Filters.poll(update) + update.message.poll = 'test' + assert Filters.poll(update) + def test_language_filter_single(self, update): update.message.from_user.language_code = 'en_US' assert (Filters.language('en_US'))(update)