diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 67e5d435d..c7761579d 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -214,13 +214,67 @@ class Filters(object): class _StatusUpdate(BaseFilter): + class _NewChatMembers(BaseFilter): + + def filter(self, message): + return bool(message.new_chat_members) + + new_chat_members = _NewChatMembers() + + class _LeftChatMember(BaseFilter): + + def filter(self, message): + return bool(message.left_chat_member) + + left_chat_member = _LeftChatMember() + + class _NewChatTitle(BaseFilter): + + def filter(self, message): + return bool(message.new_chat_title) + + new_chat_title = _NewChatTitle() + + class _NewChatPhoto(BaseFilter): + + def filter(self, message): + return bool(message.new_chat_photo) + + new_chat_photo = _NewChatPhoto() + + class _DeleteChatPhoto(BaseFilter): + + def filter(self, message): + return bool(message.delete_chat_photo) + + delete_chat_photo = _DeleteChatPhoto() + + class _ChatCreated(BaseFilter): + + def filter(self, message): + return bool(message.group_chat_created or message.supergroup_chat_created or + message.channel_chat_created) + + chat_created = _ChatCreated() + + class _Migrate(BaseFilter): + + def filter(self, message): + return bool(message.migrate_from_chat_id or message.migrate_to_chat_id) + + migrate = _Migrate() + + class _PinnedMessage(BaseFilter): + + def filter(self, message): + return bool(message.pinned_message) + + pinned_message = _PinnedMessage() + def filter(self, message): - return bool(message.new_chat_members or message.left_chat_member - or message.new_chat_title or message.new_chat_photo - or message.delete_chat_photo or message.group_chat_created - or message.supergroup_chat_created or message.channel_chat_created - or message.migrate_to_chat_id or message.migrate_from_chat_id - or message.pinned_message) + return (self.new_chat_members | self.left_chat_member | self.new_chat_title | + self.new_chat_photo | self.delete_chat_photo | self.chat_created | + self.migrate | self.pinned_message)(message) status_update = _StatusUpdate()