1.2 теперь способна работать с базами данных
This commit is contained in:
@@ -12,16 +12,18 @@ from ProjectsFiles import BotVar
|
|||||||
# Настройки экспорта в модули
|
# Настройки экспорта в модули
|
||||||
__all__ = ("CommandHandler",)
|
__all__ = ("CommandHandler",)
|
||||||
|
|
||||||
|
from SQLite3 import base_sql
|
||||||
|
|
||||||
|
|
||||||
# Класс-шаблон для команд
|
# Класс-шаблон для команд
|
||||||
class CommandHandler:
|
class CommandHandler:
|
||||||
def __init__(self, name: str, keywords: list, func=None, text_msg: str = None, chat_action: bool = False,
|
def __init__(self, name: str, keywords: list, func=None, text_msg: str = None, chat_action: bool = False,
|
||||||
description: str = "Описание команды", tg_links: 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,
|
ignore_case: bool = True, activate_keywoards: bool = True,
|
||||||
activate_commands: bool = True, activate_callback: bool = True,
|
activate_commands: bool = True, activate_callback: bool = True,
|
||||||
media: str = "message", path_to_media=None, parse_mode: str = BotVar.parse_mode,
|
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.router = Router(name=f"{name}_router")
|
||||||
self.name = name
|
self.name = name
|
||||||
@@ -65,12 +67,15 @@ class CommandHandler:
|
|||||||
async def handler(self, message: types.Message):
|
async def handler(self, message: types.Message):
|
||||||
"""Основной хэндлер команды."""
|
"""Основной хэндлер команды."""
|
||||||
try:
|
try:
|
||||||
if self.func:
|
if self.func: # Проверяем, что функция не None
|
||||||
await self.func(message) # Вызов переданной функции, если она есть
|
# Выполняем все функции из списка
|
||||||
|
for func in self.func:
|
||||||
|
await func(message)
|
||||||
if self.tg_links:
|
if self.tg_links:
|
||||||
self.text_msg = self.text_msg.replace("<users>", str(message.from_user.id))
|
self.text_msg = self.text_msg.replace("<users>", str(message.from_user.id))
|
||||||
|
|
||||||
Logs.info(log_type=self.log_type, user=username(message), text=f"использовал(а) команду /{self.name}")
|
Logs.info(log_type=self.log_type, user=username(message), text=f"использовал(а) команду /{self.name}")
|
||||||
|
await base_sql(message)
|
||||||
|
|
||||||
if self.media == "message":
|
if self.media == "message":
|
||||||
await message.reply(
|
await message.reply(
|
||||||
|
|||||||
Reference in New Issue
Block a user