mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-11-03 11:32:37 +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.
113 lines
3.9 KiB
Python
113 lines
3.9 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Satellite Pass Command - Provides satellite pass information
|
|
"""
|
|
|
|
from ..models import MeshMessage
|
|
from ..solar_conditions import get_next_satellite_pass
|
|
from .base_command import BaseCommand
|
|
|
|
|
|
class SatpassCommand(BaseCommand):
|
|
"""Command to get satellite pass information"""
|
|
|
|
# Plugin metadata
|
|
# Read-only informational output; safe for scheduled {cmd:...} rendering.
|
|
render_safe = True
|
|
name = "satpass"
|
|
honors_skip_channel_check = False
|
|
enabled_attr = "satpass_enabled"
|
|
keywords = ['satpass']
|
|
description = "Get satellite pass info: satpass <NORAD_number_or_shortcut> [visual]"
|
|
category = "solar"
|
|
requires_internet = True # Requires internet access for N2YO API
|
|
|
|
# Documentation
|
|
short_description = "Get satellite pass predictions"
|
|
usage = "satpass <NORAD_number|shortcut> [visual]"
|
|
examples = ["satpass iss", "satpass 25544 visual"]
|
|
parameters = [
|
|
{"name": "satellite", "description": "NORAD ID or shortcut (iss, hst, starlink)"},
|
|
{"name": "visual", "description": "Add 'visual' for visible passes only"}
|
|
]
|
|
|
|
# Common satellite shortcuts
|
|
SATELLITE_SHORTCUTS = {
|
|
'iss': '25544',
|
|
'hst': '20580', # Hubble Space Telescope
|
|
'hubble': '20580',
|
|
'starlink': '44294', # Example Starlink satellite
|
|
'tiangong': '48274', # Tiangong space station
|
|
'goes18': '51850', # GOES-18 weather satellite
|
|
}
|
|
|
|
def __init__(self, bot):
|
|
"""Initialize the satpass command.
|
|
|
|
Args:
|
|
bot: The bot instance.
|
|
"""
|
|
super().__init__(bot)
|
|
self.satpass_enabled = self.get_config_value('Satpass_Command', 'enabled', fallback=True, value_type='bool')
|
|
|
|
async def execute(self, message: MeshMessage) -> bool:
|
|
"""Execute the satpass command.
|
|
|
|
Args:
|
|
message: The message triggering the command.
|
|
|
|
Returns:
|
|
bool: True if executed successfully, False otherwise.
|
|
"""
|
|
try:
|
|
# Check if user provided a satellite number
|
|
content = message.content.strip()
|
|
if content == 'satpass':
|
|
# No satellite specified, show short usage (fits message length limit)
|
|
await self.send_response(message, self.translate('commands.satpass.usage_short'))
|
|
return True
|
|
|
|
# Extract satellite identifier from command
|
|
parts = content.split()
|
|
if len(parts) < 2:
|
|
error_msg = self.translate('commands.satpass.no_satellite')
|
|
await self.send_response(message, error_msg)
|
|
return True
|
|
|
|
satellite_input = parts[1].lower()
|
|
|
|
# Check for "visual" or "vis" option
|
|
use_visual = False
|
|
if len(parts) >= 3:
|
|
option = parts[2].lower()
|
|
if option in ['visual', 'vis']:
|
|
use_visual = True
|
|
|
|
# Check if it's a shortcut first
|
|
if satellite_input in self.SATELLITE_SHORTCUTS:
|
|
satellite = self.SATELLITE_SHORTCUTS[satellite_input]
|
|
else:
|
|
# Assume it's a NORAD number
|
|
satellite = satellite_input
|
|
|
|
# Get satellite pass information
|
|
pass_info = get_next_satellite_pass(satellite, use_visual=use_visual)
|
|
|
|
# Send response
|
|
response = self.translate('commands.satpass.header', pass_info=pass_info)
|
|
await self.send_response(message, response)
|
|
return True
|
|
|
|
except Exception as e:
|
|
error_msg = self.translate('commands.satpass.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.satpass.description')
|