2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 21:07:59 +00:00

Add client field in Message

This commit is contained in:
Dan 2018-04-26 12:10:54 +02:00
parent bd0fc27a61
commit dcbce9f9a1
2 changed files with 13 additions and 6 deletions

View File

@ -476,7 +476,8 @@ def parse_message(
document=document,
views=message.views,
via_bot=parse_user(users.get(message.via_bot_id, None)),
outgoing=message.out
outgoing=message.out,
client=client
)
if message.reply_to_msg_id and replies:
@ -575,7 +576,8 @@ def parse_message_service(
migrate_to_chat_id=int("-100" + str(migrate_to_chat_id)) if migrate_to_chat_id else None,
migrate_from_chat_id=-migrate_from_chat_id if migrate_from_chat_id else None,
group_chat_created=group_chat_created,
channel_chat_created=channel_chat_created
channel_chat_created=channel_chat_created,
client=client
# TODO: supergroup_chat_created
)
@ -590,4 +592,4 @@ def parse_message_empty(
client,
message: types.MessageEmpty
) -> pyrogram_types.Message:
return pyrogram_types.Message(message_id=message.id)
return pyrogram_types.Message(message_id=message.id, client=client)

View File

@ -30,6 +30,9 @@ class Message(Object):
Args:
message_id (``int``):
Unique message identifier inside this chat.
client (:obj:`Client <pyrogram.Client>`, *optional*):
The client instance this message is bound to.
date (``int``, *optional*):
Date the message was sent in Unix time.
@ -177,17 +180,17 @@ class Message(Object):
via_bot (:obj:`User <pyrogram.User>`):
Via bot.
outgoing (``bool``):
outgoing (``bool``, *optional*):
Whether the message is incoming or outgoing.
Messages received from other chats are incoming (*outgoing* is False).
Messages sent from yourself to other chats are outgoing (*outgoing* is True).
An exception is made for your own personal chat; messages sent there will be incoming.
matches (``list``):
matches (``list``, *optional*):
A list containing all `Match Objects <https://docs.python.org/3/library/re.html#match-objects>`_ that match
the text of this message. Only applicable when using :obj:`Filters.regex <pyrogram.Filters.regex>`.
command (``list``):
command (``list``, *optional*):
A list containing the command and its arguments, if any.
E.g.: "/start 1 2 3" would produce ["start", "1", "2", "3"].
Only applicable when using :obj:`Filters.command <pyrogram.Filters.command>`.
@ -196,6 +199,7 @@ class Message(Object):
def __init__(
self,
message_id: int,
client=None,
date: int = None,
chat=None,
from_user=None,
@ -244,6 +248,7 @@ class Message(Object):
command: list = None
):
self.message_id = message_id # int
self.client = client
self.date = date # int
self.chat = chat # Chat
self.from_user = from_user # flags.0?User