mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
fixed strings and case sensitiveness in /cerca
This commit is contained in:
parent
e903c6484f
commit
84cb24a51a
1 changed files with 3 additions and 3 deletions
|
@ -298,14 +298,14 @@ def cmd_search(bot: Bot, update: Update):
|
||||||
text = update.message.text.split(" ", 1)[1]
|
text = update.message.text.split(" ", 1)[1]
|
||||||
if text is None:
|
if text is None:
|
||||||
return
|
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"
|
messageText = "Ecco i risulati della ricerca:\n"
|
||||||
for entry in entries[:5]:
|
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:
|
if len(entries)>5:
|
||||||
messageText += "ci sono altre entrate del diario che corrispondono alla ricerca:\n"
|
messageText += "ci sono altre entrate del diario che corrispondono alla ricerca:\n"
|
||||||
for entry in entries[5:]:
|
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")
|
bot.send_message(update.message.chat.id, messageText, parse_mode="Markdown")
|
||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
Loading…
Reference in a new issue