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": {}, }