Skip to content

Commit b3e211a

Browse files
author
0xMett
committed
feat(services): expose chat title methods in ModerationService
Add get_all_chats_with_titles() and find_chats_by_title() delegation, and update register_chat to forward the title parameter.
1 parent 6cab1f1 commit b3e211a

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/python_italy_bot/services/moderation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from telegram import ChatPermissions
44

55
from ..db.base import AsyncRepository
6-
from ..db.models import KnownUser
6+
from ..db.models import Chat, KnownUser
77

88

99
class ModerationService:
@@ -61,14 +61,22 @@ async def is_globally_banned(self, user_id: int) -> bool:
6161
"""Check if user is globally banned."""
6262
return await self._repo.is_globally_banned(user_id)
6363

64-
async def register_chat(self, chat_id: int) -> None:
64+
async def register_chat(self, chat_id: int, title: str | None = None) -> None:
6565
"""Register a chat where the bot is active."""
66-
await self._repo.register_chat(chat_id)
66+
await self._repo.register_chat(chat_id, title)
6767

6868
async def get_all_chats(self) -> list[int]:
6969
"""Get all tracked chat IDs."""
7070
return await self._repo.get_all_chats()
7171

72+
async def get_all_chats_with_titles(self) -> list[Chat]:
73+
"""Get all tracked chats with their titles."""
74+
return await self._repo.get_all_chats_with_titles()
75+
76+
async def find_chats_by_title(self, query: str) -> list[Chat]:
77+
"""Find tracked chats whose title contains the query (case-insensitive)."""
78+
return await self._repo.find_chats_by_title(query)
79+
7280
async def add_mute(
7381
self,
7482
user_id: int,

0 commit comments

Comments
 (0)