Fix ResolveUsernameRequest may return ChannelForbidden

This commit is contained in:
Lonami Exo 2018-03-13 12:43:59 +01:00
parent 935de0afbb
commit a134336536

View File

@ -2312,7 +2312,8 @@ class TelegramClient(TelegramBareClient):
return self.get_me()
result = self(ResolveUsernameRequest(username))
for entity in itertools.chain(result.users, result.chats):
if entity.username.lower() == username:
if getattr(entity, 'username', None) or ''\
.lower() == username:
return entity
try:
# Nobody with this username, maybe it's an exact name/title