Simplify .process_entities() flow

This commit is contained in:
Lonami Exo 2017-12-27 12:58:50 +01:00
parent f96d88d3b5
commit 843e777eba

View File

@ -318,26 +318,23 @@ class Session:
try: try:
p = utils.get_input_peer(e, allow_self=False) p = utils.get_input_peer(e, allow_self=False)
marked_id = utils.get_peer_id(p, add_mark=True) marked_id = utils.get_peer_id(p, add_mark=True)
except ValueError:
continue
p_hash = None p_hash = getattr(p, 'access_hash', 0)
if isinstance(p, InputPeerChat): if p_hash is None:
p_hash = 0
elif p.access_hash:
# Some users and channels seem to be returned without # Some users and channels seem to be returned without
# an 'access_hash', meaning Telegram doesn't want you # an 'access_hash', meaning Telegram doesn't want you
# to access them. This is the reason behind ensuring # to access them. This is the reason behind ensuring
# that the 'access_hash' is non-zero. See issue #354. # that the 'access_hash' is non-zero. See issue #354.
p_hash = p.access_hash continue
if p_hash is not None:
username = getattr(e, 'username', None) or None username = getattr(e, 'username', None) or None
if username is not None: if username is not None:
username = username.lower() username = username.lower()
phone = getattr(e, 'phone', None) phone = getattr(e, 'phone', None)
name = utils.get_display_name(e) or None name = utils.get_display_name(e) or None
rows.append((marked_id, p_hash, username, phone, name)) rows.append((marked_id, p_hash, username, phone, name))
except ValueError:
pass
if not rows: if not rows:
return return