Переименование файлов и директорий

This commit is contained in:
Armatik
2024-08-16 22:53:33 +03:00
parent 2f634a4eef
commit 1fbe2b0c18
112 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1 @@
from .main import module_init

View File

@@ -0,0 +1,21 @@
{
"id": "standard.help",
"name": "Help",
"description": "Модуль для вывода /help сообщения",
"author": "Karkas Team",
"version": "1.0.0",
"privileged": false,
"dependencies": {
"required": {
"standard.config": "^1.0.0"
},
"optional": {
"standard.command_helper": "^1.0.0"
}
},
"pythonDependencies": {
"required": {
"string": "*"
}
}
}

View File

@@ -0,0 +1,81 @@
import string
from typing import TYPE_CHECKING
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import Message
from karkas_core.modules_system.public_api import (
get_metainfo,
get_module,
register_router,
)
if TYPE_CHECKING:
from karkas_blocks.standard.config import IConfig
config: "IConfig" = get_module("standard.config", "config")
try:
(register_command, get_user_commands) = get_module(
"standard.command_helper", ["register_command", "get_user_commands"]
)
COMMAND_HELPER_MODULE_LOADED = True
except Exception:
COMMAND_HELPER_MODULE_LOADED = False
pass
FOOTER = """===
Разработано командой ALT Gnome Infrastructure в рамках проекта Каркас.
Исходный код: https://gitflic.ru/project/alt-gnome/karkas
Оставить репорт: https://gitflic.ru/project/alt-gnome/karkas/issue/create
Руководитель проекта: Семен Фомченков
Ведущий разработчик: Максим Слипенко
Версия: $version
"""
def format_commands(commands_dict):
formatted_commands = []
for command, details in commands_dict.items():
formatted_commands.append(f"/{command} - {details['description']}")
return "\n".join(formatted_commands)
async def help(message: Message):
commands = ""
version = ""
if COMMAND_HELPER_MODULE_LOADED:
commands = format_commands(get_user_commands())
metainfo = get_metainfo()
if "app_version" in metainfo:
version = metainfo["app_version"]
await message.reply(
string.Template(config.get("help::message") + "\n\n" + FOOTER).substitute(
commands=commands, version=version or "не указана"
)
)
async def module_init():
config.register(
"help::message",
"string",
default_value="$commands",
)
router = Router()
router.message.register(help, Command("help"))
register_router(router)
if COMMAND_HELPER_MODULE_LOADED:
register_command("help", "Cправка")