From f5e15868f3445bffe2116c7f23374ecabc9ac7b7 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Tue, 20 Aug 2024 18:23:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/karkas_blocks/karkas_blocks/standard/chats/__init__.py | 4 ++-- src/karkas_blocks/karkas_blocks/standard/chats/main.py | 6 ++++-- src/karkas_core/karkas_core/singleton.py | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/karkas_blocks/karkas_blocks/standard/chats/__init__.py b/src/karkas_blocks/karkas_blocks/standard/chats/__init__.py index 7a66bb9..35f6775 100644 --- a/src/karkas_blocks/karkas_blocks/standard/chats/__init__.py +++ b/src/karkas_blocks/karkas_blocks/standard/chats/__init__.py @@ -3,7 +3,7 @@ from karkas_core.modules_system.public_api import ( register_outer_message_middleware, ) -from .main import UsersMiddleware +from .main import ChatsMiddleware def module_init(): @@ -12,4 +12,4 @@ def module_init(): register_app_config(APP_CONFIG) - register_outer_message_middleware(UsersMiddleware()) + register_outer_message_middleware(ChatsMiddleware()) diff --git a/src/karkas_blocks/karkas_blocks/standard/chats/main.py b/src/karkas_blocks/karkas_blocks/standard/chats/main.py index 469314f..f0b8a5b 100644 --- a/src/karkas_blocks/karkas_blocks/standard/chats/main.py +++ b/src/karkas_blocks/karkas_blocks/standard/chats/main.py @@ -7,9 +7,11 @@ from .db.tables import ChatInfo async def update_chat_info(chat: Chat): + chat_name = chat.title if chat.type != "private" else "" + await ChatInfo.insert( ChatInfo( - chat_name=chat.title, + chat_name=chat_name, ) ).on_conflict( action="DO UPDATE", @@ -19,7 +21,7 @@ async def update_chat_info(chat: Chat): ).run() -class UsersMiddleware(BaseMiddleware): +class ChatsMiddleware(BaseMiddleware): async def __call__( self, handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]], diff --git a/src/karkas_core/karkas_core/singleton.py b/src/karkas_core/karkas_core/singleton.py index d0db542..3a0f1f4 100644 --- a/src/karkas_core/karkas_core/singleton.py +++ b/src/karkas_core/karkas_core/singleton.py @@ -22,4 +22,5 @@ class Singleton(metaclass=SingletonMeta): "_fsm_storage": MemoryStorage(), "_routers": [], "_outer_message_middlewares": [], + "metainfo": {}, }