This repository has been archived on 2025-09-07. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
MouseyBot/Mousey/Bot/Handlers/Admin/utils.py

46 lines
1.2 KiB
Python

from aiogram.types import Message
from aiogram.utils.i18n import gettext as _
from sqlalchemy.ext.asyncio import AsyncSession
from aiogram.filters.command import CommandObject
from Mousey.Misc import UserRole
from Mousey.Database import update_user_role
async def cmd_sticker_id(message: Message):
"""
Отправка ID стикера.
"""
await message.answer(
text=str(message.sticker.file_id),
)
async def cmd_update_role(
message: Message,
command: CommandObject,
session: AsyncSession,
) -> None:
"""
Обновление роли по ID.
"""
args = (
command.args if command.args is None else command.args.split()
)
roles = [role.value for role in UserRole]
if args is None or not (
len(args) == 2 and args[0] in roles and args[1].isdigit()
):
await message.answer(
text=_(
"Обновление роли, необходимо ввести существующую роль"
).format(roles=roles),
)
return
await update_user_role(session, int(args[1]), args[0])
await message.answer(
text=_("Обновление роли, роль успешно обновлена"),
)