From 0006703daf114b5eafd71684ed6812a3cee314ba Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 30 Aug 2023 14:03:08 +0200 Subject: [PATCH] Fixed stupid mistake of using an empty list --- modules/search_name.py | 4 +++- modules/search_nearby.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/search_name.py b/modules/search_name.py index 7c918c4..3377021 100644 --- a/modules/search_name.py +++ b/modules/search_name.py @@ -46,7 +46,7 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None query = {"$text": {"$search": answer.text}} - locations = (await col_locations.find(query).limit(6).to_list()).reverse() + locations = await col_locations.find(query).limit(6).to_list() if len(locations) == 0: await message.reply_text( @@ -61,6 +61,8 @@ async def search_name(app: PyroClient, message: Message) -> Union[Location, None ) continue + locations = locations.reverse() + keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations]) diff --git a/modules/search_nearby.py b/modules/search_nearby.py index 332a9ea..30af99b 100644 --- a/modules/search_nearby.py +++ b/modules/search_nearby.py @@ -24,7 +24,7 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No } } - locations = (await col_locations.find(query).limit(6).to_list()).reverse() + locations = await col_locations.find(query).limit(6).to_list() if len(locations) == 0: await message.reply_text( @@ -32,6 +32,8 @@ async def search_nearby(app: PyroClient, message: Message) -> Union[Location, No ) return await search_name(app, message) + locations = locations.reverse() + keyboard = ReplyKeyboard(resize_keyboard=True, row_width=2) keyboard.add(*[ReplyButton(db_record["name"]) for db_record in locations])