Don't unnecessarily refetch the sender twice

This commit is contained in:
Lonami Exo 2022-10-03 13:11:48 +02:00
parent 299b090cde
commit db29e9b7ef

View File

@ -46,6 +46,9 @@ class SenderGetter(abc.ABC):
# cached information, they may use the property instead.
if (self._sender is None or getattr(self._sender, 'min', None)) \
and await self.get_input_sender():
# self.get_input_sender may refresh in which case the sender may no longer be min
# However it could still incur a cost so the cheap check is done twice instead.
if self._sender is None or getattr(self._sender, 'min', None):
try:
self._sender =\
await self._client.get_entity(self._input_sender)