示例#1
0
async def remove_alias_wrapper(message: Message, alias_name: str, **kwargs):
    db = Database.get_current()
    logger.info(f"Удаление алиаса\n")
    alias_name = delete_last_space(alias_name)
    for alias in db.aliases:
        if alias_name == alias.name:
            remove_alias(db, alias)
            await edit_message(message, f"✅ Алиас <<{alias_name}>> удален")
            return

    await edit_message(message, f'⚠ Алиас <<{alias_name}>> не найден')
示例#2
0
async def add_alias_wrapper(message: Message, alias_name: str,
                            command_from: str, command_to: str, **kwargs):
    db = Database.get_current()
    logger.info(f"Создание алиаса\n")
    alias_name = delete_last_space(alias_name)
    command_from = delete_last_space(command_from)
    command_to = delete_last_space(command_to)

    for alias in db.aliases:
        if alias_name == alias.name:
            await edit_message(message,
                               f"⚠ Алиас <<{alias_name}>> уже существует")
            return

    new_alias = add_alias(db, alias_name, command_from, command_to)
    await edit_message(
        message, f"✅ Новый алиас <<{alias_name}>> создан\n"
        f"Команды: {new_alias.command_from} -> !л {command_to}")
示例#3
0
async def import_aliases_wrapper(message: Message, pack_name: str, **kwargs):
    db = Database.get_current()
    alias_packs = get_alias_packs()
    if pack_name not in alias_packs.keys():
        await edit_message(message, "⚠ Пак не найден")
        return

    logger.info(f"Импорт алиасов\n")
    pack = alias_packs[pack_name]

    if not check_name_duplicates(db, pack):
        await edit_message(message,
                           "⚠ Не удалось импортировать пак. Есть дубликаты.")
        return

    db.aliases.extend(pack)
    db.save()
    await edit_message(
        message, f"Импортированно {len(pack)} алиасов\n" +
        generate_aliases_pack_description(pack))
示例#4
0
async def show_aliases_wrapper(message: Message, **kwargs):
    db = Database.get_current()
    logger.info(f"Просмотр алиасов\n")
    await edit_message(message, show_aliases(db))