Files
meshcore-bot/modules/commands/reload_command.py
T
agessaman 23da88c37d refactor(shared): create shared/ package and migrate foundation modules
Move models.py, db_manager.py, db_migrations.py, and security_utils.py
from modules/ to a new shared/ top-level package that can be imported by
both the bot and the web viewer without coupling them.

Update all imports across ~75 files (commands, service plugins, tests,
web viewer, generate_website.py). No logic changes — pure file moves and
import path updates.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 17:19:46 -07:00

69 lines
2.0 KiB
Python

#!/usr/bin/env python3
"""
Reload Command
Allows admin users to reload the bot configuration without restarting
"""
from shared.models import MeshMessage
from .base_command import BaseCommand
class ReloadCommand(BaseCommand):
"""Command for reloading bot configuration"""
# Plugin metadata
name = "reload"
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 can_execute(self, message: MeshMessage, skip_channel_check: bool = False) -> bool:
"""Check if this command can be executed (admin only)"""
if not self.requires_admin_access():
return False
return super().can_execute(message)
def requires_admin_access(self) -> bool:
"""Reload command requires admin access"""
return True
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