Files
meshcore-bot/modules/commands/reload_command.py
T
agessaman efe074b151 refactor: restore behavior the branch had changed (codex review)
A codex review of the branch found seven places where earlier refactor commits changed behavior. Each is restored here with a test:

- base_service imported flood_scope relatively; the local-service loader also runs that file as local_services.base_service, where the import cannot resolve. Now absolute.
- Radio-health fields were initialized after commands and services were built, so a plugin constructor reading is_radio_offline raised. They are now set before any plugin.
- Removing the per-command can_execute overrides made 31 commands honor skip_channel_check, which their overrides had dropped. BaseCommand.honors_skip_channel_check (False on exactly those commands) keeps them enforcing their channel list.
- CommandManager.get_plugin_metadata, WxCommand.get_weather_for_zipcode and PluginLoader.validate_plugin were public compatibility entry points; they are back.
- feed_manager stopped exporting DEFAULT_MAX_FEED_RESPONSE_BYTES and DEFAULT_MAX_PARSED_FEED_ITEMS despite the commit saying it re-exported them; it does now.
- wx and gwx logged companion-location lookup failures at WARNING; the shared helper logged at debug. It now takes the level.
- The INFO 'MESSAGE ROUTING' / 'DIRECT MESSAGE' lines for pubkey-correlated DMs were removed with the dead path_info computation; they are logged again by a log-only helper.
2026-10-01 06:53:14 -07:00

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) -> 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