Improve search response if no results found

This commit is contained in:
Tulir Asokan
2018-02-11 17:31:34 +02:00
parent 04714a2975
commit 33d39166c4
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -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:**", ""]
+2
View File
@@ -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: