Портфолио: Рефакторинг кода

This commit is contained in:
Kirill Samoylenkov 2025-08-22 21:11:08 +07:00
parent f6a2c1fa30
commit 5c18e22b80
31 changed files with 447 additions and 283 deletions

View file

@ -2,7 +2,9 @@ import json
from aiogram import Bot
from aiogram.types.bot_command import BotCommand
from aiogram.types.bot_command_scope_all_private_chats import BotCommandScopeAllPrivateChats
from aiogram.types.bot_command_scope_all_private_chats import (
BotCommandScopeAllPrivateChats,
)
from loguru import logger
@ -11,10 +13,12 @@ from Mousey.Misc import BOT_SETTINGS_DIR
async def set_profile_info(bot: Bot) -> None:
"""
Установка всей информации в профиле для бота.
Имя, описание, аватар...
Установка всей информации в профиле для бота.
Имя, описание, аватар...
"""
with open(BOT_SETTINGS_DIR / "settings.json", "r", encoding="utf-8") as file:
with open(
BOT_SETTINGS_DIR / "settings.json", "r", encoding="utf-8"
) as file:
bot_info = json.load(file)
await bot.set_my_name(bot_info["name"])
@ -26,19 +30,22 @@ async def set_profile_info(bot: Bot) -> None:
async def set_command_menu(bot: Bot) -> None:
"""
Установка меню пользовательских команд в Telegram для бота.
Установка меню пользовательских команд в Telegram для бота.
"""
with open(BOT_SETTINGS_DIR / "settings.json", "r", encoding="utf-8") as file:
with open(
BOT_SETTINGS_DIR / "settings.json", "r", encoding="utf-8"
) as file:
bot_info = json.load(file)
await bot.set_my_commands(
[
BotCommand(command=command_info["name"], description=command_info["description"])
BotCommand(
command=command_info["name"],
description=command_info["description"],
)
for command_info in bot_info["commands"]
],
scope=BotCommandScopeAllPrivateChats(),
)
logger.info("Меню команд для бота настроено.")