mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-31 18:12:45 +00:00
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.
77 lines
2.3 KiB
Python
77 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Solar Command - Provides solar conditions and HF band information
|
|
"""
|
|
|
|
from ..models import MeshMessage
|
|
from ..solar_conditions import solar_conditions
|
|
from .base_command import BaseCommand
|
|
|
|
|
|
class SolarCommand(BaseCommand):
|
|
"""Command to get solar conditions.
|
|
|
|
Provides information about current solar activity (SFI, sunspots, A-index, K-index)
|
|
and improved HF band conditions.
|
|
"""
|
|
|
|
# Plugin metadata
|
|
# Read-only informational output; safe for scheduled {cmd:...} rendering.
|
|
render_safe = True
|
|
name = "solar"
|
|
honors_skip_channel_check = False
|
|
enabled_attr = "solar_enabled"
|
|
keywords = ['solar']
|
|
description = "Get current solar conditions and HF band info"
|
|
category = "solar"
|
|
requires_internet = True # Requires internet access for hamqsl.com API
|
|
|
|
# Documentation
|
|
short_description = "Get current solar conditions and HF band info"
|
|
usage = "solar"
|
|
examples = ["solar"]
|
|
|
|
def __init__(self, bot):
|
|
"""Initialize the solar command.
|
|
|
|
Args:
|
|
bot: The MeshCoreBot instance.
|
|
"""
|
|
super().__init__(bot)
|
|
self.solar_enabled = self.get_config_value('Solar_Command', 'enabled', fallback=True, value_type='bool')
|
|
|
|
async def execute(self, message: MeshMessage) -> bool:
|
|
"""Execute the solar command.
|
|
|
|
Retrieves solar conditions and sends a formatted response to the user.
|
|
|
|
Args:
|
|
message: The message that triggered the command.
|
|
|
|
Returns:
|
|
bool: True if executed successfully, False otherwise.
|
|
"""
|
|
try:
|
|
# Get solar conditions (more readable format)
|
|
solar_info = solar_conditions()
|
|
|
|
# Send response (solar only, more readable)
|
|
response = self.translate('commands.solar.response', info=solar_info)
|
|
|
|
# Use the unified send_response method
|
|
return await self.send_response(message, response)
|
|
|
|
|
|
except Exception as e:
|
|
error_msg = self.translate('commands.solar.error', error=str(e))
|
|
await self.send_response(message, error_msg)
|
|
return False
|
|
|
|
def get_help_text(self) -> str:
|
|
"""Get help text for this command.
|
|
|
|
Returns:
|
|
str: The help text for this command.
|
|
"""
|
|
return self.translate('commands.solar.help')
|