mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add raw attribute to Message class
This commit is contained in:
parent
def5ccbc4a
commit
35f2867b28
@ -376,6 +376,9 @@ class Message(Object, Update):
|
|||||||
reactions (List of :obj:`~pyrogram.types.Reaction`):
|
reactions (List of :obj:`~pyrogram.types.Reaction`):
|
||||||
List of the reactions to this message.
|
List of the reactions to this message.
|
||||||
|
|
||||||
|
raw (``pyrogram.raw.types.Message``, *optional*):
|
||||||
|
The raw message object, as received from the Telegram API.
|
||||||
|
|
||||||
link (``str``, *property*):
|
link (``str``, *property*):
|
||||||
Generate a link to this message, only for groups and channels.
|
Generate a link to this message, only for groups and channels.
|
||||||
"""
|
"""
|
||||||
@ -483,7 +486,8 @@ class Message(Object, Update):
|
|||||||
"types.ReplyKeyboardRemove",
|
"types.ReplyKeyboardRemove",
|
||||||
"types.ForceReply"
|
"types.ForceReply"
|
||||||
] = None,
|
] = None,
|
||||||
reactions: List["types.Reaction"] = None
|
reactions: List["types.Reaction"] = None,
|
||||||
|
raw: "raw.types.Message" = None
|
||||||
):
|
):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
@ -577,9 +581,10 @@ class Message(Object, Update):
|
|||||||
self.gift_code = gift_code
|
self.gift_code = gift_code
|
||||||
self.requested_chats = requested_chats
|
self.requested_chats = requested_chats
|
||||||
self.giveaway_launched = giveaway_launched
|
self.giveaway_launched = giveaway_launched
|
||||||
self.reactions = reactions
|
|
||||||
self.chat_ttl_period = chat_ttl_period
|
self.chat_ttl_period = chat_ttl_period
|
||||||
self.boosts_applied = boosts_applied
|
self.boosts_applied = boosts_applied
|
||||||
|
self.reactions = reactions
|
||||||
|
self.raw = raw
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def _parse(
|
async def _parse(
|
||||||
@ -592,7 +597,7 @@ class Message(Object, Update):
|
|||||||
replies: int = 1
|
replies: int = 1
|
||||||
):
|
):
|
||||||
if isinstance(message, raw.types.MessageEmpty):
|
if isinstance(message, raw.types.MessageEmpty):
|
||||||
return Message(id=message.id, empty=True, client=client)
|
return Message(id=message.id, empty=True, client=client, raw=message)
|
||||||
|
|
||||||
from_id = utils.get_raw_peer_id(message.from_id)
|
from_id = utils.get_raw_peer_id(message.from_id)
|
||||||
peer_id = utils.get_raw_peer_id(message.peer_id)
|
peer_id = utils.get_raw_peer_id(message.peer_id)
|
||||||
@ -769,6 +774,7 @@ class Message(Object, Update):
|
|||||||
requested_chats=requested_chats,
|
requested_chats=requested_chats,
|
||||||
chat_ttl_period=chat_ttl_period,
|
chat_ttl_period=chat_ttl_period,
|
||||||
boosts_applied=boosts_applied,
|
boosts_applied=boosts_applied,
|
||||||
|
raw=message,
|
||||||
client=client
|
client=client
|
||||||
# TODO: supergroup_chat_created
|
# TODO: supergroup_chat_created
|
||||||
)
|
)
|
||||||
@ -1047,6 +1053,7 @@ class Message(Object, Update):
|
|||||||
outgoing=message.out,
|
outgoing=message.out,
|
||||||
reply_markup=reply_markup,
|
reply_markup=reply_markup,
|
||||||
reactions=reactions,
|
reactions=reactions,
|
||||||
|
raw=message,
|
||||||
client=client
|
client=client
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,16 +60,22 @@ class Object:
|
|||||||
if isinstance(obj, datetime):
|
if isinstance(obj, datetime):
|
||||||
return str(obj)
|
return str(obj)
|
||||||
|
|
||||||
|
attributes_to_hide = [
|
||||||
|
"raw"
|
||||||
|
]
|
||||||
|
|
||||||
|
filtered_attributes = {
|
||||||
|
attr: ("*" * 9 if attr == "phone_number" else getattr(obj, attr))
|
||||||
|
for attr in filter(
|
||||||
|
lambda x: not x.startswith("_") and x not in attributes_to_hide,
|
||||||
|
obj.__dict__,
|
||||||
|
)
|
||||||
|
if getattr(obj, attr) is not None
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"_": obj.__class__.__name__,
|
"_": obj.__class__.__name__,
|
||||||
**{
|
**filtered_attributes
|
||||||
attr: (
|
|
||||||
"*" * 9 if attr == "phone_number" else
|
|
||||||
getattr(obj, attr)
|
|
||||||
)
|
|
||||||
for attr in filter(lambda x: not x.startswith("_"), obj.__dict__)
|
|
||||||
if getattr(obj, attr) is not None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user