diff --git a/AUTHORS.rst b/AUTHORS.rst index 9c33bc522..90267d60b 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -20,6 +20,7 @@ The following wonderful people contributed directly or indirectly to this projec - `jh0ker `_ - `JRoot3D `_ - `jlmadurga `_ +- `Kjwon15 `_ - `Li-aung Yip `_ - `macrojames `_ - `Michael Elovskikh `_ diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index c8ecd0336..c16db36cf 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -107,6 +107,13 @@ class Filters(object): 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): diff --git a/tests/test_filters.py b/tests/test_filters.py index 902a64cc1..1ef5e7db5 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -51,6 +51,14 @@ class FiltersTest(BaseTest, unittest.TestCase): 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))