mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-31 10:02:38 +00:00
S4. BaseCommand and the 40 bundled overrides that took no argument now take `message: MeshMessage | None = None`, matching joke and rain, which already use the message. None of the 40 bodies read it, so their help text is unchanged. help and command_manager keep their TypeError retry, since local plugins may still implement get_help_text(self). For bundled commands the retry no longer runs: `help <command>` calls get_help_text(message) once instead of failing and calling it again. A new test pins the signature for every bundled command class. The offline smoke run against the real config produces the same help text for all 46 commands.
61 lines
1.7 KiB
Python
61 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Reload Command
|
|
Allows admin users to reload the bot configuration without restarting
|
|
"""
|
|
|
|
from ..models import MeshMessage
|
|
from .base_command import BaseCommand
|
|
|
|
|
|
class ReloadCommand(BaseCommand):
|
|
"""Command for reloading bot configuration"""
|
|
|
|
# Plugin metadata
|
|
name = "reload"
|
|
honors_skip_channel_check = False
|
|
admin_only = True
|
|
keywords = ["reload", "reloadconfig", "configreload"]
|
|
description = "Reload bot configuration without restart (DM only, admin only)"
|
|
requires_dm = True
|
|
cooldown_seconds = 2
|
|
category = "admin"
|
|
|
|
def __init__(self, bot):
|
|
"""Initialize the reload command.
|
|
|
|
Args:
|
|
bot: The bot instance.
|
|
"""
|
|
super().__init__(bot)
|
|
|
|
def get_help_text(self, message: MeshMessage | None = None) -> str:
|
|
"""Get help text for the reload command.
|
|
|
|
Returns:
|
|
str: The help text for this command.
|
|
"""
|
|
return ("Reloads the bot configuration from config.ini without restarting.\n"
|
|
"Note: Radio/connection settings cannot be changed via reload.\n"
|
|
"If radio settings changed, restart the bot instead.\n"
|
|
"Usage: reload")
|
|
|
|
async def execute(self, message: MeshMessage) -> bool:
|
|
"""Execute the reload command.
|
|
|
|
Args:
|
|
message: The message triggering the command.
|
|
|
|
Returns:
|
|
bool: True if executed successfully, False otherwise.
|
|
"""
|
|
# Call the bot's reload_config method
|
|
success, msg = self.bot.reload_config()
|
|
|
|
if success:
|
|
await self.send_response(message, f"✓ {msg}")
|
|
else:
|
|
await self.send_response(message, f"✗ {msg}")
|
|
|
|
return True
|