From 6ff84b32f42c768846cd28ec836227261c8db978 Mon Sep 17 00:00:00 2001 From: Verum Date: Wed, 26 Feb 2025 09:18:50 +0700 Subject: [PATCH] =?UTF-8?q?1.2=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=D0=BD=D0=B0=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D1=82=D1=8C=20=D1=81=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B8=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BotLibrary/samples/user_cmd_class.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/BotLibrary/samples/user_cmd_class.py b/BotLibrary/samples/user_cmd_class.py index b58b3d3..2c5a3d3 100644 --- a/BotLibrary/samples/user_cmd_class.py +++ b/BotLibrary/samples/user_cmd_class.py @@ -12,16 +12,18 @@ from ProjectsFiles import BotVar # Настройки экспорта в модули __all__ = ("CommandHandler",) +from SQLite3 import base_sql + # Класс-шаблон для команд class CommandHandler: def __init__(self, name: str, keywords: list, func=None, text_msg: str = None, chat_action: bool = False, description: str = "Описание команды", tg_links: bool = False, - keyboard=None, prefix=BotVar.prefix, callbackdata=None, only_admin: bool = False, + keyboard=None, prefix=BotVar.prefix, callbackdata: list =None, only_admin: bool = False, ignore_case: bool = True, activate_keywoards: bool = True, activate_commands: bool = True, activate_callback: bool = True, media: str = "message", path_to_media=None, parse_mode: str = BotVar.parse_mode, - disable_notification: bool = False, protect: bool = True, ): + disable_notification: bool = BotVar.disable_notification, protect: bool = BotVar.protect_content, ): self.router = Router(name=f"{name}_router") self.name = name @@ -65,12 +67,15 @@ class CommandHandler: async def handler(self, message: types.Message): """Основной хэндлер команды.""" try: - if self.func: - await self.func(message) # Вызов переданной функции, если она есть + if self.func: # Проверяем, что функция не None + # Выполняем все функции из списка + for func in self.func: + await func(message) if self.tg_links: self.text_msg = self.text_msg.replace("", str(message.from_user.id)) Logs.info(log_type=self.log_type, user=username(message), text=f"использовал(а) команду /{self.name}") + await base_sql(message) if self.media == "message": await message.reply(