d4bf750c9e
Initial commit
92 lines
1.4 KiB
Python
92 lines
1.4 KiB
Python
from services.profile_manager import load_profile, save_profile
|
|
|
|
|
|
def set_attach(
|
|
slot: int,
|
|
name: str,
|
|
description: str,
|
|
icon: str = "",
|
|
mini_icon: str = ""
|
|
):
|
|
"""
|
|
Меняет один из 6 attach-слотов
|
|
"""
|
|
|
|
if slot < 1 or slot > 6:
|
|
raise ValueError("Attach slot должен быть от 1 до 6")
|
|
|
|
|
|
profile = load_profile()
|
|
|
|
|
|
attachments = profile.setdefault(
|
|
"attachments",
|
|
[
|
|
{},
|
|
{},
|
|
{},
|
|
{},
|
|
{},
|
|
{}
|
|
]
|
|
)
|
|
|
|
|
|
attachments[slot - 1] = {
|
|
"name": name,
|
|
"description": description,
|
|
"icon": icon,
|
|
"mini_icon": mini_icon
|
|
}
|
|
|
|
|
|
profile["attachments"] = attachments
|
|
|
|
|
|
save_profile(profile)
|
|
|
|
|
|
return attachments[slot - 1]
|
|
|
|
|
|
|
|
def get_attach(slot: int):
|
|
|
|
if slot < 1 or slot > 6:
|
|
raise ValueError("Attach slot должен быть от 1 до 6")
|
|
|
|
|
|
profile = load_profile()
|
|
|
|
|
|
attachments = profile.get(
|
|
"attachments",
|
|
[
|
|
{},
|
|
{},
|
|
{},
|
|
{},
|
|
{},
|
|
{}
|
|
]
|
|
)
|
|
|
|
|
|
return attachments[slot - 1]
|
|
|
|
|
|
|
|
def clear_attach(slot: int):
|
|
|
|
if slot < 1 or slot > 6:
|
|
raise ValueError("Attach slot должен быть от 1 до 6")
|
|
|
|
|
|
profile = load_profile()
|
|
|
|
|
|
profile["attachments"][slot - 1] = {}
|
|
|
|
|
|
save_profile(profile)
|