Files
meshcore-bot/modules/commands/version_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

52 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""
Version command for the MeshCore Bot.
Returns the currently running bot version string.
"""
from typing import Any
from shared.models import MeshMessage
from ..version_info import resolve_runtime_version
from .base_command import BaseCommand
class VersionCommand(BaseCommand):
"""Handles the version/ver command."""
name = "version"
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 can_execute(self, message: MeshMessage, skip_channel_check: bool = False) -> bool:
if not self.version_enabled:
return False
return super().can_execute(message, skip_channel_check=skip_channel_check)
def get_help_text(self) -> str:
return self.description
async def execute(self, message: MeshMessage) -> bool:
version_value = getattr(self.bot, "bot_version", None)
if not version_value:
bot_root = getattr(self.bot, "bot_root", ".")
version_value = resolve_runtime_version(bot_root).get("display", "unknown")
sender = message.sender_id or "Unknown"
response = f"@[{sender}] Bot version: {version_value}"
return await self.send_response(message, response)