Fetch user details in case they are missing

This commit is contained in:
Dan 2021-12-07 19:40:06 +01:00
parent 34b6002c68
commit 85ee6c3785

View File

@ -433,6 +433,16 @@ class Message(Object, Update):
is_scheduled: bool = False,
replies: int = 1
):
user_id = utils.get_raw_peer_id(message.from_id) or utils.get_raw_peer_id(message.peer_id)
if user_id not in users:
r = (await client.send(
raw.functions.users.GetUsers(
id=[await client.resolve_peer(user_id)]
)
))[0]
users[r.id] = r
if isinstance(message, raw.types.MessageEmpty):
return Message(message_id=message.id, empty=True, client=client)
@ -499,8 +509,7 @@ class Message(Object, Update):
voice_chat_members_invited = types.VoiceChatMembersInvited._parse(client, action, users)
service_type = "voice_chat_members_invited"
user = utils.get_raw_peer_id(message.from_id) or utils.get_raw_peer_id(message.peer_id)
from_user = types.User._parse(client, users.get(user, None))
from_user = types.User._parse(client, users.get(user_id, None))
sender_chat = types.Chat._parse(client, message, users, chats) if not from_user else None
parsed_message = Message(
@ -554,8 +563,6 @@ class Message(Object, Update):
except MessageIdsEmpty:
pass
return parsed_message
if isinstance(message, raw.types.Message):
@ -696,8 +703,7 @@ class Message(Object, Update):
else:
reply_markup = None
user = utils.get_raw_peer_id(message.from_id) or utils.get_raw_peer_id(message.peer_id)
from_user = types.User._parse(client, users.get(user, None))
from_user = types.User._parse(client, users.get(user_id, None))
sender_chat = types.Chat._parse(client, message, users, chats) if not from_user else None
parsed_message = Message(