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
11 changes: 11 additions & 0 deletions telegram/ext/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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`
"""
4 changes: 4 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down