fixed stuck in memory function. implemented random memory

This commit is contained in:
Lia Schöneweiß
2023-05-24 15:02:17 +02:00
committed by Remy Moll
parent 49339ebcb9
commit 0860196a53
5 changed files with 135 additions and 29 deletions

View File

@@ -30,7 +30,6 @@ class MemoryHandler(BaseHandler):
search_string = " ".join(context.args)
if search_string == '~photo':
matching_models = self.models.JournalEntry.select().where(self.models.JournalEntry.media_path != "").order_by(self.models.JournalEntry.date)
else: # searching for text
@@ -40,7 +39,12 @@ class MemoryHandler(BaseHandler):
)
).order_by(self.models.JournalEntry.date)
# exit if no memory matches the string
if len(matching_models) == 0:
await update.message.reply_text(f"There is no matching memory yet.")
return ConversationHandler.END
options = [[InlineKeyboardButton(m.date_pretty, callback_data=i)] for i,m in enumerate(matching_models)]
keyboard = InlineKeyboardMarkup(options)