mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Add poll messages support to filters (#1673)
This commit is contained in:
parent
62f514f068
commit
d9d65cc2ac
3 changed files with 15 additions and 0 deletions
|
@ -26,6 +26,7 @@ The following wonderful people contributed directly or indirectly to this projec
|
|||
- `d-qoi <https://github.com/d-qoi>`_
|
||||
- `daimajia <https://github.com/daimajia>`_
|
||||
- `Daniel Reed <https://github.com/nmlorg>`_
|
||||
- `Eana Hufwe <https://github.com/blueset>`_
|
||||
- `Ehsan Online <https://github.com/ehsanonline>`_
|
||||
- `Eli Gao <https://github.com/eligao>`_
|
||||
- `Emilio Molinari <https://github.com/xates>`_
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue