Merge branch 'develop' into asyncio

This commit is contained in:
Dan 2018-11-08 11:14:20 +01:00
commit 3b7580739b
3 changed files with 54 additions and 38 deletions

View File

@ -619,6 +619,7 @@ async def parse_messages(
forward_signature=forward_signature,
forward_date=forward_date,
mentioned=message.mentioned,
media=bool(media) or None,
edit_date=message.edit_date,
media_group_id=message.grouped_id,
photo=photo,
@ -740,6 +741,7 @@ async def parse_messages(
date=message.date,
chat=parse_chat(message, users, chats),
from_user=parse_user(users.get(message.from_id, None)),
service=True,
new_chat_members=new_chat_members,
left_chat_member=left_chat_member,
new_chat_title=new_chat_title,
@ -763,7 +765,7 @@ async def parse_messages(
except MessageIdsEmpty:
pass
else:
m = pyrogram_types.Message(message_id=message.id, client=proxy(client))
m = pyrogram_types.Message(message_id=message.id, client=proxy(client), empty=True)
parsed_messages.append(m)

View File

@ -166,11 +166,38 @@ class Filters:
inline_keyboard = create("InlineKeyboard", lambda _, m: isinstance(m.reply_markup, InlineKeyboardMarkup))
"""Filter messages containing inline keyboard markups"""
dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162))
mentioned = create("Mentioned", lambda _, m: bool(m.mentioned))
"""Filter messages containing mentions"""
service = create("Service", lambda _, m: bool(m.service))
"""Filter service messages. A service message contains any of the following fields set
- left_chat_member
- new_chat_title
- new_chat_photo
- delete_chat_photo
- group_chat_created
- supergroup_chat_created
- channel_chat_created
- migrate_to_chat_id
- migrate_from_chat_id
- pinned_message"""
media = create("Media", lambda _, m: bool(m.media))
"""Filter media messages. A media message contains any of the following fields set
- audio
- document
- photo
- sticker
- video
- animation
- voice
- video_note
- contact
- location
- venue"""
@staticmethod
def command(command: str or list,
prefix: str or list = "/",
@ -307,38 +334,4 @@ class Filters:
and not message.outgoing))
)
service = create(
"Service",
lambda _, m: bool(
Filters.new_chat_members(m)
or Filters.left_chat_member(m)
or Filters.new_chat_title(m)
or Filters.new_chat_photo(m)
or Filters.delete_chat_photo(m)
or Filters.group_chat_created(m)
or Filters.supergroup_chat_created(m)
or Filters.channel_chat_created(m)
or Filters.migrate_to_chat_id(m)
or Filters.migrate_from_chat_id(m)
or Filters.pinned_message(m)
)
)
"""Filter all service messages."""
media = create(
"Media",
lambda _, m: bool(
Filters.audio(m)
or Filters.document(m)
or Filters.photo(m)
or Filters.sticker(m)
or Filters.video(m)
or Filters.animation(m)
or Filters.voice(m)
or Filters.video_note(m)
or Filters.contact(m)
or Filters.location(m)
or Filters.venue(m)
)
)
"""Filter all media messages."""
dan = create("Dan", lambda _, m: bool(m.from_user and m.from_user.id == 23122162))

View File

@ -58,6 +58,21 @@ class Message(Object):
mentioned (``bool``, *optional*):
The message contains a mention.
empty (``bool``, *optional*):
The message is empty.
A message can be empty in case it was deleted or you tried to retrieve a message that doesn't exist yet.
service (``bool``, *optional*):
The message is a service message.
A service message has one and only one of these fields set: left_chat_member, new_chat_title,
new_chat_photo, delete_chat_photo, group_chat_created, supergroup_chat_created, channel_chat_created,
migrate_to_chat_id, migrate_from_chat_id, pinned_message.
media (``bool``` *optional*):
The message is a media message.
A media message has one and only one of these fields set: audio, document, photo, sticker, video, animation,
voice, video_note, contact, location, venue.
edit_date (``int``, *optional*):
Date the message was last edited in Unix time.
@ -210,6 +225,9 @@ class Message(Object):
forward_date: int = None,
reply_to_message=None,
mentioned=None,
empty=None,
service=None,
media=None,
edit_date: int = None,
media_group_id: str = None,
author_signature: str = None,
@ -258,6 +276,9 @@ class Message(Object):
self.forward_date = forward_date # flags.5?int
self.reply_to_message = reply_to_message # flags.6?Message
self.mentioned = mentioned
self.empty = empty
self.service = service
self.media = media
self.edit_date = edit_date # flags.7?int
self.media_group_id = media_group_id # flags.8?string
self.author_signature = author_signature # flags.9?string