From 5e54c0a19b713effd7edd6cfd4d0dc08a6e1c312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Fri, 21 Mar 2025 19:30:09 -0300 Subject: [PATCH 1/2] Fix Message is too long in show_projects, written by Facundo Batista --- src/pycamp_bot/commands/projects.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pycamp_bot/commands/projects.py b/src/pycamp_bot/commands/projects.py index 8dca8ec..6dbc0fa 100644 --- a/src/pycamp_bot/commands/projects.py +++ b/src/pycamp_bot/commands/projects.py @@ -452,7 +452,11 @@ async def delete_project(update, context): async def show_projects(update, context): """Show available projects""" projects = Project.select() - text = [] + if not projects: + text = "Todavía no hay ningún proyecto cargado" + await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True)) + + msg_text = "" for project in projects: project_text = "{}\n Owner: @{}\n Temática: {}\n Nivel: {}\n Repositorio: {}\n Grupo de Telegram: {}".format( project.name, @@ -466,15 +470,15 @@ async def show_projects(update, context): (Vote.project == project) & (Vote.interest)).count() if participants_count > 0: project_text += "\n Interesades: {}".format(participants_count) - text.append(project_text) - if text: - text = "\n\n".join(text) - else: - text = "Todavía no hay ningún proyecto cargado" + if len(msg_text) + len(project_text) > 4096: + await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True)) + msg_text = "" - await update.message.reply_text(text, link_preview_options=LinkPreviewOptions(is_disabled=True)) + msg_text += "\n\n" + project_text + if msg_text: + await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True)) async def show_participants(update, context): From 83386da2e1e993ea3a14fd01ee29a18d9d64c1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Fri, 21 Mar 2025 19:35:15 -0300 Subject: [PATCH 2/2] Fix variable name --- src/pycamp_bot/commands/projects.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pycamp_bot/commands/projects.py b/src/pycamp_bot/commands/projects.py index 6dbc0fa..b83e489 100644 --- a/src/pycamp_bot/commands/projects.py +++ b/src/pycamp_bot/commands/projects.py @@ -453,7 +453,7 @@ async def show_projects(update, context): """Show available projects""" projects = Project.select() if not projects: - text = "Todavía no hay ningún proyecto cargado" + msg_text = "Todavía no hay ningún proyecto cargado" await update.message.reply_text(msg_text, link_preview_options=LinkPreviewOptions(is_disabled=True)) msg_text = ""