allow search public chats

This commit is contained in:
2021-12-11 10:47:07 +08:00
parent 9a021e3c5b
commit 34915a2649
2 changed files with 16 additions and 2 deletions

View File

@@ -28,8 +28,13 @@ async def get_chat_id_from_name(lib: TdLib, name: str) -> int:
raise ValueError('Can not found chat.')
le = len(re['chat_ids'])
if le == 0:
raise ValueError('No chat found.')
elif le == 1:
re = await lib.searchPublicChats(name)
if re is None:
raise ValueError('Can not search public chats.')
le = len(re['chat_ids'])
if le == 0:
raise ValueError('No chat found.')
if le == 1:
return re['chat_ids'][0]
else:
raise NotImplementedError('Multiply chat is returned.')