From 792ee49593acf5e0d2cc30766a5c09cbb61f3d70 Mon Sep 17 00:00:00 2001 From: Joan Date: Fri, 15 Dec 2023 11:00:08 +0100 Subject: [PATCH] Added help command and feedback when closing conjunta --- conjuntasbot/conjuntasbot.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/conjuntasbot/conjuntasbot.py b/conjuntasbot/conjuntasbot.py index aba6a1b..b06cd04 100644 --- a/conjuntasbot/conjuntasbot.py +++ b/conjuntasbot/conjuntasbot.py @@ -562,6 +562,8 @@ async def close_conjunta(update: Update, context: CallbackContext): # Desanclamos el mensaje await context.bot.unpin_chat_message(group_chat_id, message_id) + + await context.bot.send_message(chat_id=user_id, text=f"La conjunta para {product_name} ha sido cerrada correctamente.") else: await context.bot.send_message(chat_id=user_id, text="Solo el administrador puede cerrar la conjunta.") else: @@ -659,6 +661,16 @@ async def send_message_to_admins(update: Update, context: CallbackContext, messa except Exception as e: logging.error(f"Error sending message to {admin_id}: {e}") +async def help(update: Update, context: CallbackContext): + user_id = update.effective_user.id + + # Verifica si el usuario es administrador + if user_id in admin_ids: + message = "Comandos disponibles:\n\n" + message += "/admin_summary - Muestra las conjuntas activas, permite modificarlas y cerrarlas\n" + message += "/start_conjunta - Inicia una nueva conjunta\n" + await update.message.reply_text(text=message, parse_mode=ParseMode.HTML) + def main()->None: application = Application.builder().get_updates_http_version('1.1').http_version('1.1').token(bot_token).build() @@ -684,6 +696,7 @@ def main()->None: application.add_handler(CallbackQueryHandler(show_conjunta_details, pattern="info \d")) application.add_handler(CallbackQueryHandler(close_conjunta, pattern="close \d")) application.add_handler(MessageHandler(filters.REPLY, handle_conjunta)) + application.add_handler(CommandHandler('help', help)) application.run_polling()