diff --git a/AUTHORS.rst b/AUTHORS.rst index 300892358..3de882279 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 013e6b27f..b375bc9f0 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -956,6 +956,15 @@ officedocument.wordprocessingml.document")``- 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 b1525b87e..a48ba2d55 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -599,6 +599,11 @@ class TestFilters(object): 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)