Skip to content

Commit

Permalink
Assert user/channel ID is non-zero too for #392
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Jan 6, 2018
1 parent f2fbdc6 commit f357d00
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions telethon/tl/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,19 @@ def process_entities(self, tlo):
except ValueError:
continue

p_hash = getattr(p, 'access_hash', 0)
if p_hash is None:
# Some users and channels seem to be returned without
# an 'access_hash', meaning Telegram doesn't want you
# to access them. This is the reason behind ensuring
# that the 'access_hash' is non-zero. See issue #354.
if isinstance(p, (InputPeerUser, InputPeerChannel)):
if not p.access_hash:
# Some users and channels seem to be returned without
# an 'access_hash', meaning Telegram doesn't want you
# to access them. This is the reason behind ensuring
# that the 'access_hash' is non-zero. See issue #354.
# Note that this checks for zero or None, see #392.
continue
else:
p_hash = p.access_hash
elif isinstance(p, InputPeerChat):
p_hash = 0
else:
continue

username = getattr(e, 'username', None) or None
Expand Down

0 comments on commit f357d00

Please sign in to comment.