mirror of
https://github.com/lifegpc/pythonscript.git
synced 2026-06-06 11:28:58 +08:00
allow search public chats
This commit is contained in:
9
tdlib.py
9
tdlib.py
@@ -445,6 +445,15 @@ class TdLib:
|
||||
print(f"{re['code']} {re['message']}")
|
||||
return None
|
||||
|
||||
async def searchPublicChats(self, query: str):
|
||||
re = await self._send({"@type": "searchPublicChats", "query": query})
|
||||
if re['@type'] == 'chats':
|
||||
return re
|
||||
else:
|
||||
if re['@type'] == 'error':
|
||||
print(f"{re['code']} {re['message']}")
|
||||
return None
|
||||
|
||||
async def setAuthenticationPhoneNumber(self, phone_number, settings=None):
|
||||
sett = {"@type": "phoneNumberAuthenticationSettings",
|
||||
"allow_flash_call": False,
|
||||
|
||||
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user