|
1 | 1 | from typing import TYPE_CHECKING, List, Optional |
2 | 2 |
|
| 3 | +from enum import Enum |
3 | 4 | from . import BaseManager |
4 | 5 | from ..dataclasses import Room |
5 | 6 | from ..misc import stringify_bulk |
|
8 | 9 | from ..misc.api_responses import RoomResponse, RoomSearchResponse |
9 | 10 | from ..rest import Response |
10 | 11 |
|
| 12 | +class RoomInclude(Enum): |
| 13 | + """ |
| 14 | + Enum which corresponds to the room include parameter values |
| 15 | + """ |
| 16 | + SUBROOMS = 2 |
| 17 | + ROLES = 4 |
| 18 | + TAGS = 8 |
| 19 | + PROMO_CONTENT = 32 |
| 20 | + SCORES = 64 |
| 21 | + LOADING_SCREENS = 256 |
| 22 | + |
| 23 | +def sum_enum_list(enums: List[Enum]) -> int: |
| 24 | + """ |
| 25 | + Sums a list of integer enums |
| 26 | +
|
| 27 | + :param enums: A list of enums that have integer values |
| 28 | + :return: Sum of the enums' values |
| 29 | + """ |
| 30 | + sum = 0 |
| 31 | + for i in enums: |
| 32 | + sum += i.value |
| 33 | + return sum |
| 34 | + |
11 | 35 | class RoomManager(BaseManager['Room', 'RoomResponse']): |
12 | 36 | """ |
13 | 37 | This is a factory object for creating room objects. Its the |
14 | 38 | main interface for fetching room related data. |
15 | 39 | """ |
16 | | - async def get(self, name: str, include: int = 0) -> 'Room': |
| 40 | + async def get(self, name: str, include: int | List[RoomInclude] = 0) -> 'Room': |
17 | 41 | """ |
18 | 42 | Gets room data by their name, and returns it as an room object. |
19 | 43 | Returns nothing if the room doesn't exist or is private. |
@@ -44,7 +68,7 @@ async def get(self, name: str, include: int = 0) -> 'Room': |
44 | 68 | return self.create_dataclass(room_data, room_data) |
45 | 69 | return None |
46 | 70 |
|
47 | | - async def fetch(self, id: int, include: int = 0) -> 'Room': |
| 71 | + async def fetch(self, id: int, include: int | List[RoomInclude] = 0) -> 'Room': |
48 | 72 | """ |
49 | 73 | Gets room data by their id, and returns it as an room object. |
50 | 74 | Returns nothing if the room doesn't exist or is private. |
|
0 commit comments