|
2 | 2 |
|
3 | 3 | from abc import ABC, abstractmethod |
4 | 4 |
|
| 5 | +from .models import KnownUser |
| 6 | + |
5 | 7 |
|
6 | 8 | class Repository(ABC): |
7 | 9 | """Abstract interface for data persistence (sync).""" |
@@ -136,6 +138,53 @@ def is_globally_banned(self, user_id: int) -> bool: |
136 | 138 | """Check if user is globally banned.""" |
137 | 139 | ... |
138 | 140 |
|
| 141 | + # -- Known users (user tracking) -- |
| 142 | + |
| 143 | + @abstractmethod |
| 144 | + def upsert_known_user( |
| 145 | + self, |
| 146 | + user_id: int, |
| 147 | + username: str | None, |
| 148 | + first_name: str | None, |
| 149 | + last_name: str | None, |
| 150 | + ) -> None: |
| 151 | + """Insert or update a known user's info.""" |
| 152 | + ... |
| 153 | + |
| 154 | + @abstractmethod |
| 155 | + def get_known_user(self, user_id: int) -> KnownUser | None: |
| 156 | + """Get a known user by ID.""" |
| 157 | + ... |
| 158 | + |
| 159 | + @abstractmethod |
| 160 | + def get_known_user_by_username(self, username: str) -> KnownUser | None: |
| 161 | + """Get a known user by username (case-insensitive).""" |
| 162 | + ... |
| 163 | + |
| 164 | + # -- Welcomed users (welcome-once-per-group) -- |
| 165 | + |
| 166 | + @abstractmethod |
| 167 | + def has_been_welcomed(self, user_id: int, chat_id: int) -> bool: |
| 168 | + """Check if user has already been welcomed in this chat.""" |
| 169 | + ... |
| 170 | + |
| 171 | + @abstractmethod |
| 172 | + def mark_welcomed(self, user_id: int, chat_id: int) -> None: |
| 173 | + """Mark user as having been welcomed in this chat.""" |
| 174 | + ... |
| 175 | + |
| 176 | + # -- Welcome delay -- |
| 177 | + |
| 178 | + @abstractmethod |
| 179 | + def get_welcome_delay(self, chat_id: int) -> int | None: |
| 180 | + """Get welcome message auto-delete delay in minutes for a chat.""" |
| 181 | + ... |
| 182 | + |
| 183 | + @abstractmethod |
| 184 | + def set_welcome_delay(self, chat_id: int, minutes: int | None) -> None: |
| 185 | + """Set welcome message auto-delete delay. None to reset to default.""" |
| 186 | + ... |
| 187 | + |
139 | 188 |
|
140 | 189 | class AsyncRepository(ABC): |
141 | 190 | """Abstract interface for data persistence (async).""" |
@@ -270,6 +319,53 @@ async def is_globally_banned(self, user_id: int) -> bool: |
270 | 319 | """Check if user is globally banned.""" |
271 | 320 | ... |
272 | 321 |
|
| 322 | + # -- Known users (user tracking) -- |
| 323 | + |
| 324 | + @abstractmethod |
| 325 | + async def upsert_known_user( |
| 326 | + self, |
| 327 | + user_id: int, |
| 328 | + username: str | None, |
| 329 | + first_name: str | None, |
| 330 | + last_name: str | None, |
| 331 | + ) -> None: |
| 332 | + """Insert or update a known user's info.""" |
| 333 | + ... |
| 334 | + |
| 335 | + @abstractmethod |
| 336 | + async def get_known_user(self, user_id: int) -> KnownUser | None: |
| 337 | + """Get a known user by ID.""" |
| 338 | + ... |
| 339 | + |
| 340 | + @abstractmethod |
| 341 | + async def get_known_user_by_username(self, username: str) -> KnownUser | None: |
| 342 | + """Get a known user by username (case-insensitive).""" |
| 343 | + ... |
| 344 | + |
| 345 | + # -- Welcomed users (welcome-once-per-group) -- |
| 346 | + |
| 347 | + @abstractmethod |
| 348 | + async def has_been_welcomed(self, user_id: int, chat_id: int) -> bool: |
| 349 | + """Check if user has already been welcomed in this chat.""" |
| 350 | + ... |
| 351 | + |
| 352 | + @abstractmethod |
| 353 | + async def mark_welcomed(self, user_id: int, chat_id: int) -> None: |
| 354 | + """Mark user as having been welcomed in this chat.""" |
| 355 | + ... |
| 356 | + |
| 357 | + # -- Welcome delay -- |
| 358 | + |
| 359 | + @abstractmethod |
| 360 | + async def get_welcome_delay(self, chat_id: int) -> int | None: |
| 361 | + """Get welcome message auto-delete delay in minutes for a chat.""" |
| 362 | + ... |
| 363 | + |
| 364 | + @abstractmethod |
| 365 | + async def set_welcome_delay(self, chat_id: int, minutes: int | None) -> None: |
| 366 | + """Set welcome message auto-delete delay. None to reset to default.""" |
| 367 | + ... |
| 368 | + |
273 | 369 | async def close(self) -> None: |
274 | 370 | """Close any resources (override if needed).""" |
275 | 371 | pass |
0 commit comments