Files
meshcore-bot/modules/commands/reload_command.py
Stacy Olivas ad77d7b00d fix: BUG-025/026/027/028/029 implementations and ruff/mypy refinements
BUG-025: send_channel_message retry logic on no_event_received
BUG-026: split_text_into_chunks and chunked dispatch in message_handler
BUG-027: test_weekly_on_wrong_day_does_not_run patch uses fake_now
BUG-028: byte_data = b"" initialised before try in decode_meshcore_packet
BUG-029: app.py db_path via self._config_base; realtime.html socket race
  fixed; base.html forceNew removed; ping_timeout 5 to 20s

Additional: ruff and mypy refinements across all modules; discord bridge,
telegram bridge, rate limiter, and service plugin updates
2026-03-17 18:07:19 -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 ..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