mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-25 00:34:19 +03:00
Except TypeError on empty access hash from 5018879
thoroughly
This commit is contained in:
parent
6839bfcc2d
commit
09f994c105
|
@ -150,9 +150,9 @@ class EventCommon(ChatGetter, abc.ABC):
|
|||
if not self._chat:
|
||||
return
|
||||
|
||||
self._input_chat = utils.get_input_peer(self._chat)
|
||||
if not getattr(self._input_chat, 'access_hash', True):
|
||||
# getattr with True to handle the InputPeerSelf() case
|
||||
try:
|
||||
self._input_chat = utils.get_input_peer(self._chat)
|
||||
except TypeError:
|
||||
try:
|
||||
self._input_chat = self._client.session.get_input_entity(
|
||||
self._chat_peer
|
||||
|
|
|
@ -30,8 +30,11 @@ class Forward(ChatGetter, SenderGetter):
|
|||
|
||||
self._sender_id = original.from_id
|
||||
self._sender = entities.get(original.from_id)
|
||||
self._input_sender =\
|
||||
utils.get_input_peer(self._sender) if self._sender else None
|
||||
try:
|
||||
self._input_sender =\
|
||||
utils.get_input_peer(self._sender) if self._sender else None
|
||||
except TypeError:
|
||||
self._input_sender = None
|
||||
|
||||
self._broadcast = None
|
||||
if original.channel_id:
|
||||
|
@ -41,7 +44,10 @@ class Forward(ChatGetter, SenderGetter):
|
|||
self._chat_peer = None
|
||||
self._chat = None
|
||||
|
||||
self._input_chat = \
|
||||
utils.get_input_peer(self._chat) if self._chat else None
|
||||
try:
|
||||
self._input_chat = \
|
||||
utils.get_input_peer(self._chat) if self._chat else None
|
||||
except TypeError:
|
||||
self._input_chat = None
|
||||
|
||||
# TODO We could reload the message
|
||||
|
|
|
@ -204,18 +204,17 @@ class Message(ChatGetter, SenderGetter, TLObject, abc.ABC):
|
|||
self._client = client
|
||||
self._sender = entities.get(self._sender_id)
|
||||
if self._sender:
|
||||
self._input_sender = utils.get_input_peer(self._sender)
|
||||
if not getattr(self._input_sender, 'access_hash', True):
|
||||
try:
|
||||
self._input_sender = utils.get_input_peer(self._sender)
|
||||
except TypeError:
|
||||
self._input_sender = None
|
||||
|
||||
self._chat = entities.get(self.chat_id)
|
||||
self._input_chat = input_chat
|
||||
if not self._input_chat and self._chat:
|
||||
self._input_chat = utils.get_input_peer(self._chat)
|
||||
if not getattr(self._input_chat, 'access_hash', True):
|
||||
# Telegram may omit the hash in updates -> invalid peer
|
||||
# However things like InputPeerSelf() or InputPeerChat(id)
|
||||
# are still valid so default to getting "True" on not found
|
||||
try:
|
||||
self._input_chat = utils.get_input_peer(self._chat)
|
||||
except TypeError:
|
||||
self._input_chat = None
|
||||
|
||||
if self.fwd_from:
|
||||
|
|
Loading…
Reference in New Issue
Block a user