From 0d5cab62b0d077ad7946b64a534e3914f1cc79dd Mon Sep 17 00:00:00 2001 From: Igor Tolmachov Date: Sat, 3 Dec 2022 18:20:16 +0900 Subject: 2.0 --- handlers/config.py | 3 ++- handlers/gen.py | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'handlers') diff --git a/handlers/config.py b/handlers/config.py index 21d556b..7628805 100644 --- a/handlers/config.py +++ b/handlers/config.py @@ -1,4 +1,5 @@ from json import JSONDecodeError, dumps, loads +from logging import info from aiogram import types as t from pydantic import BaseModel, ValidationError @@ -42,7 +43,7 @@ async def settings_command(msg: t.Message) -> None: text = "" for field_name in path: assert ( - isinstance(config, BaseModel) and f in config.__fields__ + isinstance(config, BaseModel) and field_name in config.__fields__ ), "Параметр не найден" field_info = config.__fields__[field_name].field_info config = getattr(config, field_name) diff --git a/handlers/gen.py b/handlers/gen.py index e4398bd..72afb79 100644 --- a/handlers/gen.py +++ b/handlers/gen.py @@ -39,10 +39,9 @@ def get_text(chat_id: int) -> str: @dp.message_handler(commands=["gen"]) async def gen_command(msg: t.Message) -> None: - await msg.delete() - message = get_text(msg.chat.id) - if message is not None: - await msg.answer(message) + if config.get_config(msg.chat.id).gen.delete_command: + await msg.delete() + await msg.answer(get_text(msg.chat.id)) @dp.message_handler(commands=["del"]) @@ -64,6 +63,7 @@ async def del_command(msg: t.Message) -> None: content_types=[t.ContentType.ANY], ) async def chance_message(msg: t.Message) -> None: - message = get_text(msg.chat.id) - if message is not None: - await msg.reply(message) + if config.get_config(msg.chat.id).gen.reply: + await msg.reply(get_text(msg.chat.id)) + else: + await msg.answer(get_text(msg.chat.id)) -- cgit v1.2.3