aboutsummaryrefslogtreecommitdiff
path: root/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'handlers')
-rw-r--r--handlers/config.py3
-rw-r--r--handlers/gen.py14
2 files changed, 9 insertions, 8 deletions
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 @@
1from json import JSONDecodeError, dumps, loads 1from json import JSONDecodeError, dumps, loads
2from logging import info
2 3
3from aiogram import types as t 4from aiogram import types as t
4from pydantic import BaseModel, ValidationError 5from pydantic import BaseModel, ValidationError
@@ -42,7 +43,7 @@ async def settings_command(msg: t.Message) -> None:
42 text = "" 43 text = ""
43 for field_name in path: 44 for field_name in path:
44 assert ( 45 assert (
45 isinstance(config, BaseModel) and f in config.__fields__ 46 isinstance(config, BaseModel) and field_name in config.__fields__
46 ), "Параметр не найден" 47 ), "Параметр не найден"
47 field_info = config.__fields__[field_name].field_info 48 field_info = config.__fields__[field_name].field_info
48 config = getattr(config, field_name) 49 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:
39 39
40@dp.message_handler(commands=["gen"]) 40@dp.message_handler(commands=["gen"])
41async def gen_command(msg: t.Message) -> None: 41async def gen_command(msg: t.Message) -> None:
42 await msg.delete() 42 if config.get_config(msg.chat.id).gen.delete_command:
43 message = get_text(msg.chat.id) 43 await msg.delete()
44 if message is not None: 44 await msg.answer(get_text(msg.chat.id))
45 await msg.answer(message)
46 45
47 46
48@dp.message_handler(commands=["del"]) 47@dp.message_handler(commands=["del"])
@@ -64,6 +63,7 @@ async def del_command(msg: t.Message) -> None:
64 content_types=[t.ContentType.ANY], 63 content_types=[t.ContentType.ANY],
65) 64)
66async def chance_message(msg: t.Message) -> None: 65async def chance_message(msg: t.Message) -> None:
67 message = get_text(msg.chat.id) 66 if config.get_config(msg.chat.id).gen.reply:
68 if message is not None: 67 await msg.reply(get_text(msg.chat.id))
69 await msg.reply(message) 68 else:
69 await msg.answer(get_text(msg.chat.id))