From 8d03850d038e06b6d26d55b0c9ac456fafc81722 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Tue, 7 Dec 2021 20:22:29 +0100 Subject: [PATCH] Don't propagate errors when fetching missing user details --- pyrogram/types/messages_and_media/message.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pyrogram/types/messages_and_media/message.py b/pyrogram/types/messages_and_media/message.py index 6f2539b8..897cf26d 100644 --- a/pyrogram/types/messages_and_media/message.py +++ b/pyrogram/types/messages_and_media/message.py @@ -24,7 +24,7 @@ import pyrogram from pyrogram import raw from pyrogram import types from pyrogram import utils -from pyrogram.errors import MessageIdsEmpty +from pyrogram.errors import MessageIdsEmpty, PeerIdInvalid from pyrogram.parser import utils as parser_utils, Parser from ..object import Object from ..update import Update @@ -435,13 +435,16 @@ class Message(Object, Update): ): 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 + try: + r = (await client.send( + raw.functions.users.GetUsers( + id=[await client.resolve_peer(user_id)] + ) + ))[0] + except PeerIdInvalid: + pass + else: + users[r.id] = r if isinstance(message, raw.types.MessageEmpty): return Message(message_id=message.id, empty=True, client=client)