мелкие правки

This commit is contained in:
Maxim Slipenko 2024-08-20 18:23:31 +03:00
parent 9c9c93edf5
commit f5e15868f3
No known key found for this signature in database
GPG Key ID: 6DEA9FA7DE98C7D6
3 changed files with 7 additions and 4 deletions

View File

@ -3,7 +3,7 @@ from karkas_core.modules_system.public_api import (
register_outer_message_middleware, register_outer_message_middleware,
) )
from .main import UsersMiddleware from .main import ChatsMiddleware
def module_init(): def module_init():
@ -12,4 +12,4 @@ def module_init():
register_app_config(APP_CONFIG) register_app_config(APP_CONFIG)
register_outer_message_middleware(UsersMiddleware()) register_outer_message_middleware(ChatsMiddleware())

View File

@ -7,9 +7,11 @@ from .db.tables import ChatInfo
async def update_chat_info(chat: Chat): async def update_chat_info(chat: Chat):
chat_name = chat.title if chat.type != "private" else ""
await ChatInfo.insert( await ChatInfo.insert(
ChatInfo( ChatInfo(
chat_name=chat.title, chat_name=chat_name,
) )
).on_conflict( ).on_conflict(
action="DO UPDATE", action="DO UPDATE",
@ -19,7 +21,7 @@ async def update_chat_info(chat: Chat):
).run() ).run()
class UsersMiddleware(BaseMiddleware): class ChatsMiddleware(BaseMiddleware):
async def __call__( async def __call__(
self, self,
handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]], handler: Callable[[TelegramObject, Dict[str, Any]], Awaitable[Any]],

View File

@ -22,4 +22,5 @@ class Singleton(metaclass=SingletonMeta):
"_fsm_storage": MemoryStorage(), "_fsm_storage": MemoryStorage(),
"_routers": [], "_routers": [],
"_outer_message_middlewares": [], "_outer_message_middlewares": [],
"metainfo": {},
} }