33from datetime import datetime , timezone
44
55from .base import AsyncRepository
6- from .models import Ban , KnownUser , Mute , Report
6+ from .models import Ban , Chat , KnownUser , Mute , Report
77
88
99class InMemoryRepository (AsyncRepository ):
@@ -17,7 +17,7 @@ def __init__(self) -> None:
1717 self ._reports : list [Report ] = []
1818 self ._welcome_messages : dict [int , str ] = {}
1919 self ._globally_verified : set [int ] = set ()
20- self ._bot_chats : set [int ] = set ()
20+ self ._bot_chats : dict [int , str | None ] = {}
2121 self ._global_bans : dict [int , tuple [int , str | None ]] = {}
2222 self ._known_users : dict [int , KnownUser ] = {}
2323 self ._username_to_user_id : dict [str , int ] = {}
@@ -141,11 +141,22 @@ async def is_globally_verified(self, user_id: int) -> bool:
141141 async def mark_globally_verified (self , user_id : int ) -> None :
142142 self ._globally_verified .add (user_id )
143143
144- async def register_chat (self , chat_id : int ) -> None :
145- self ._bot_chats . add ( chat_id )
144+ async def register_chat (self , chat_id : int , title : str | None = None ) -> None :
145+ self ._bot_chats [ chat_id ] = title
146146
147147 async def get_all_chats (self ) -> list [int ]:
148- return list (self ._bot_chats )
148+ return list (self ._bot_chats .keys ())
149+
150+ async def get_all_chats_with_titles (self ) -> list [Chat ]:
151+ return [Chat (chat_id = cid , title = t ) for cid , t in self ._bot_chats .items ()]
152+
153+ async def find_chats_by_title (self , query : str ) -> list [Chat ]:
154+ query_lower = query .lower ()
155+ return [
156+ Chat (chat_id = cid , title = t )
157+ for cid , t in self ._bot_chats .items ()
158+ if t and query_lower in t .lower ()
159+ ]
149160
150161 async def add_global_ban (
151162 self ,
0 commit comments