|
@@ -619,29 +619,38 @@ This action cannot be undone.
|
|
# Add other management commands here if they have quick action buttons
|
|
# Add other management commands here if they have quick action buttons
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+ # Prepare key for map lookup, stripping leading '/' if present for general commands
|
|
|
|
+ mapped_command_key = callback_data
|
|
|
|
+ if callback_data.startswith('/') and not callback_data.startswith('/confirm_'): # Avoid stripping for confirm actions
|
|
|
|
+ mapped_command_key = callback_data[1:]
|
|
|
|
+
|
|
# Check if the callback_data matches a mapped informational/management command
|
|
# Check if the callback_data matches a mapped informational/management command
|
|
- if callback_data in command_action_map:
|
|
|
|
- command_method = command_action_map[callback_data]
|
|
|
|
|
|
+ if mapped_command_key in command_action_map:
|
|
|
|
+ command_method = command_action_map[mapped_command_key]
|
|
try:
|
|
try:
|
|
- logger.info(f"Executing {callback_data} command via button callback.")
|
|
|
|
|
|
+ logger.info(f"Executing {mapped_command_key} command (from callback: {callback_data}) via button callback.")
|
|
# Edit the original message to indicate the action is being processed
|
|
# Edit the original message to indicate the action is being processed
|
|
- # await query.edit_message_text(text=f"🔄 Processing {callback_data.capitalize()}...", parse_mode='HTML') # Optional
|
|
|
|
|
|
+ # await query.edit_message_text(text=f"🔄 Processing {mapped_command_key.capitalize()}...", parse_mode='HTML') # Optional
|
|
await command_method(update, context) # Call the actual command method
|
|
await command_method(update, context) # Call the actual command method
|
|
# After the command sends its own message(s), we might want to remove or clean up the original message with buttons.
|
|
# After the command sends its own message(s), we might want to remove or clean up the original message with buttons.
|
|
# For now, let the command method handle all responses.
|
|
# For now, let the command method handle all responses.
|
|
# Optionally, delete the message that had the buttons:
|
|
# Optionally, delete the message that had the buttons:
|
|
# await query.message.delete()
|
|
# await query.message.delete()
|
|
except Exception as e:
|
|
except Exception as e:
|
|
- logger.error(f"Error executing command '{callback_data}' from button: {e}", exc_info=True)
|
|
|
|
|
|
+ logger.error(f"Error executing command '{mapped_command_key}' from button: {e}", exc_info=True)
|
|
try:
|
|
try:
|
|
- await query.message.reply_text(f"❌ Error processing {callback_data.capitalize()}: {e}")
|
|
|
|
|
|
+ await query.message.reply_text(f"❌ Error processing {mapped_command_key.capitalize()}: {e}")
|
|
except Exception as reply_e:
|
|
except Exception as reply_e:
|
|
- logger.error(f"Failed to send error reply for {callback_data} button: {reply_e}")
|
|
|
|
|
|
+ logger.error(f"Failed to send error reply for {mapped_command_key} button: {reply_e}")
|
|
return # Handled
|
|
return # Handled
|
|
|
|
|
|
# Special handling for 'help' callback from InfoCommands quick menu
|
|
# Special handling for 'help' callback from InfoCommands quick menu
|
|
- if callback_data == "help":
|
|
|
|
- logger.info("Handling 'help' button callback. Guiding user to /help command.")
|
|
|
|
|
|
+ # This check should use the modified key as well if we want /help to work via this mechanism
|
|
|
|
+ # However, the 'help' key in command_action_map is 'help', not '/help'.
|
|
|
|
+ # The current 'help' handling is separate and specific. Let's adjust it for consistency if needed or verify.
|
|
|
|
+ # The previous change to info_commands.py made help callback_data='/help'.
|
|
|
|
+ if callback_data == "/help": # Check for the actual callback_data value
|
|
|
|
+ logger.info("Handling '/help' button callback. Guiding user to /help command.")
|
|
try:
|
|
try:
|
|
# Remove the inline keyboard from the original message and provide guidance.
|
|
# Remove the inline keyboard from the original message and provide guidance.
|
|
await query.edit_message_text(
|
|
await query.edit_message_text(
|