mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-31 10:02:38 +00:00
S4. BaseCommand and the 40 bundled overrides that took no argument now take `message: MeshMessage | None = None`, matching joke and rain, which already use the message. None of the 40 bodies read it, so their help text is unchanged. help and command_manager keep their TypeError retry, since local plugins may still implement get_help_text(self). For bundled commands the retry no longer runs: `help <command>` calls get_help_text(message) once instead of failing and calling it again. A new test pins the signature for every bundled command class. The offline smoke run against the real config produces the same help text for all 46 commands.
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Version command for the MeshCore Bot.
|
|
Returns the currently running bot version string.
|
|
"""
|
|
|
|
from typing import Any
|
|
|
|
from ..models import MeshMessage
|
|
from ..version_info import resolve_application_version
|
|
from .base_command import BaseCommand
|
|
|
|
|
|
class VersionCommand(BaseCommand):
|
|
"""Handles the version/ver command."""
|
|
|
|
# Read-only informational output; safe for scheduled {cmd:...} rendering.
|
|
|
|
render_safe = True
|
|
|
|
name = "version"
|
|
enabled_attr = "version_enabled"
|
|
keywords = ["version", "ver"]
|
|
description = "Show the running bot version."
|
|
category = "basic"
|
|
|
|
short_description = "Show running bot version"
|
|
usage = "version"
|
|
examples = ["version", "ver"]
|
|
|
|
def __init__(self, bot: Any):
|
|
super().__init__(bot)
|
|
self.version_enabled = self.get_config_value(
|
|
"Version_Command",
|
|
"enabled",
|
|
fallback=True,
|
|
value_type="bool",
|
|
)
|
|
|
|
def get_help_text(self, message: MeshMessage | None = None) -> str:
|
|
return self.description
|
|
|
|
async def execute(self, message: MeshMessage) -> bool:
|
|
version_value = getattr(self.bot, "bot_version", None)
|
|
if not version_value:
|
|
version_value = resolve_application_version().get("display", "unknown")
|
|
sender = message.sender_id or "Unknown"
|
|
response = f"@[{sender}] Bot version: {version_value}"
|
|
return await self.send_response(message, response)
|