mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-29 07:08:45 +00:00
Refactor command response handling in CmdCommand to streamline command list retrieval
- Updated the response generation in CmdCommand to allow _get_commands_list to handle the "Available commands: " prefix internally, simplifying the code and improving readability. - Removed redundant calculations for available length, enhancing maintainability.
This commit is contained in:
@@ -122,10 +122,8 @@ class CmdCommand(BaseCommand):
|
||||
# Fallback to dynamic command list if no custom keyword is defined
|
||||
# Get max message length to ensure we fit within limits
|
||||
max_length = self.get_max_message_length(message)
|
||||
# Reserve space for "Available commands: " prefix
|
||||
available_length = max_length - len("Available commands: ")
|
||||
commands_list = self._get_commands_list(max_length=available_length)
|
||||
response = f"Available commands: {commands_list}"
|
||||
# _get_commands_list handles the prefix internally
|
||||
response = self._get_commands_list(max_length=max_length)
|
||||
return await self.send_response(message, response)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error executing cmd command: {e}")
|
||||
|
||||
Reference in New Issue
Block a user