diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 72a4b30f22a..213e753137b 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -2280,6 +2280,15 @@ def filter(self, update: Update) -> bool: edited_channel_post = _EditedChannelPost() + class _Edited(UpdateFilter): + __slots__ = () + name = 'Filters.update.edited' + + def filter(self, update: Update) -> bool: + return update.edited_message is not None or update.edited_channel_post is not None + + edited = _Edited() + class _ChannelPosts(UpdateFilter): __slots__ = () name = 'Filters.update.channel_posts' @@ -2310,4 +2319,6 @@ def filter(self, update: Update) -> bool: :attr:`telegram.Update.edited_channel_post` channel_posts: Updates with either :attr:`telegram.Update.channel_post` or :attr:`telegram.Update.edited_channel_post` + edited: Updates with either :attr:`telegram.Update.edited_message` or + :attr:`telegram.Update.edited_channel_post` """ diff --git a/tests/test_filters.py b/tests/test_filters.py index efebc477faf..9077dd7a1e4 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1973,6 +1973,7 @@ def test_update_type_message(self, update): assert not Filters.update.channel_post(update) assert not Filters.update.edited_channel_post(update) assert not Filters.update.channel_posts(update) + assert not Filters.update.edited(update) assert Filters.update(update) def test_update_type_edited_message(self, update): @@ -1983,6 +1984,7 @@ def test_update_type_edited_message(self, update): assert not Filters.update.channel_post(update) assert not Filters.update.edited_channel_post(update) assert not Filters.update.channel_posts(update) + assert Filters.update.edited(update) assert Filters.update(update) def test_update_type_channel_post(self, update): @@ -1993,6 +1995,7 @@ def test_update_type_channel_post(self, update): assert Filters.update.channel_post(update) assert not Filters.update.edited_channel_post(update) assert Filters.update.channel_posts(update) + assert not Filters.update.edited(update) assert Filters.update(update) def test_update_type_edited_channel_post(self, update): @@ -2003,6 +2006,7 @@ def test_update_type_edited_channel_post(self, update): assert not Filters.update.channel_post(update) assert Filters.update.edited_channel_post(update) assert Filters.update.channel_posts(update) + assert Filters.update.edited(update) assert Filters.update(update) def test_merged_short_circuit_and(self, update, base_class):