Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `jh0ker <https://github.com/jh0ker>`_
- `JRoot3D <https://github.com/JRoot3D>`_
- `jlmadurga <https://github.com/jlmadurga>`_
- `Kjwon15 <https://github.com/kjwon15>`_
- `Li-aung Yip <https://github.com/LiaungYip>`_
- `macrojames <https://github.com/macrojames>`_
- `Michael Elovskikh <https://github.com/wronglink>`_
Expand Down
7 changes: 7 additions & 0 deletions telegram/ext/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ class _Command(BaseFilter):
def filter(self, message):
return bool(message.text and message.text.startswith('/'))

class _Reply(BaseFilter):

def filter(self, message):
return bool(message.reply_to_message)

reply = _Reply()

command = _Command()

class _Audio(BaseFilter):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def test_filters_command(self):
self.message.text = '/test'
self.assertTrue(Filters.command(self.message))

def test_filters_reply(self):
another_message = Message(1, User(1, "TestOther"), datetime.now(), Chat(0, 'private'))
self.message.text = 'test'
self.assertFalse(Filters.reply(self.message))
self.assertFalse(Filters.reply(Filters.message))
self.message.reply_to_message = another_message
self.assertTrue(Filters.reply(self.message))

def test_filters_audio(self):
self.message.audio = 'test'
self.assertTrue(Filters.audio(self.message))
Expand Down