From 84cb24a51a1856923617d3cdbe46da3baadb010d Mon Sep 17 00:00:00 2001 From: Fabio De Simone Date: Mon, 28 Jan 2019 22:33:08 +0100 Subject: [PATCH] fixed strings and case sensitiveness in /cerca --- telegrambot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telegrambot.py b/telegrambot.py index 1ec9d644..607644b0 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -298,14 +298,14 @@ def cmd_search(bot: Bot, update: Update): text = update.message.text.split(" ", 1)[1] if text is None: return - entries = session.query(db.Diario).filter(db.Diario.text.like('%'+text+'%')).all() + entries = session.query(db.Diario).filter(db.Diario.text.ilike('%'+text+'%')).all() messageText = "Ecco i risulati della ricerca:\n" for entry in entries[:5]: - messageText+="[#{entry.id}](https://ryg.steffo.eu/diario#entry-{entry.id}) di {entry.author}\n{entry.text}\n\n" + messageText+=f"[#{entry.id}](https://ryg.steffo.eu/diario#entry-{entry.id}) di {entry.author}\n{entry.text}\n\n" if len(entries)>5: messageText += "ci sono altre entrate del diario che corrispondono alla ricerca:\n" for entry in entries[5:]: - messageText += "[#{entry.id}](https://ryg.steffo.eu/diario#entry-{entry.id}) " + messageText += f"[#{entry.id}](https://ryg.steffo.eu/diario#entry-{entry.id}) " bot.send_message(update.message.chat.id, messageText, parse_mode="Markdown") finally: session.close()