Improve search response if no results found
This commit is contained in:
@@ -235,6 +235,12 @@ class CommandHandler:
|
||||
|
||||
results, remote = await evt.sender.search(query, force_remote)
|
||||
|
||||
if not results:
|
||||
if len(query) < 5 and remote:
|
||||
return await evt.reply("No local results. "
|
||||
"Minimum length of remote query is 5 characters.")
|
||||
return await evt.reply("No results 3:")
|
||||
|
||||
reply = []
|
||||
if remote:
|
||||
reply += ["**Results from Telegram server:**", ""]
|
||||
|
||||
@@ -170,6 +170,8 @@ class User:
|
||||
return results[0:max_results]
|
||||
|
||||
async def _search_remote(self, query, max_results=5):
|
||||
if len(query) < 5:
|
||||
return []
|
||||
server_results = await self.client(SearchRequest(q=query, limit=max_results))
|
||||
results = []
|
||||
for user in server_results.users:
|
||||
|
||||
Reference in New Issue
Block a user