11from typing import TYPE_CHECKING , List , Optional
22
3+ from enum import Enum
34from . import BaseManager
45from ..dataclasses import Room
56from ..misc import stringify_bulk
89 from ..misc .api_responses import RoomResponse , RoomSearchResponse
910 from ..rest import Response
1011
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+
1135class RoomManager (BaseManager ['Room' , 'RoomResponse' ]):
1236 """
1337 This is a factory object for creating room objects. Its the
1438 main interface for fetching room related data.
1539 """
16- async def get (self , name : str , include : int = 0 ) -> 'Room' :
40+ async def get (self , name : str , include : int | List [ RoomInclude ] = 0 ) -> 'Room' :
1741 """
1842 Gets room data by their name, and returns it as an room object.
1943 Returns nothing if the room doesn't exist or is private.
@@ -35,11 +59,14 @@ async def get(self, name: str, include: int = 0) -> 'Room':
3559 :param include: An integer that add additional information to the response.
3660 :return: An room object representing the data or nothing if not found.
3761 """
62+
63+ if isinstance (include , list ):
64+ include = sum_enum_list (include )
3865 data : 'Response[RoomResponse]' = await self .rec_net .rooms .rooms .make_request ('get' , params = {'name' : name , 'include' : include })
3966 if data .data : return self .create_dataclass (data .data ['RoomId' ], data .data )
4067 return None
4168
42- async def fetch (self , id : int , include : int = 0 ) -> 'Room' :
69+ async def fetch (self , id : int , include : int | List [ RoomInclude ] = 0 ) -> 'Room' :
4370 """
4471 Gets room data by their id, and returns it as an room object.
4572 Returns nothing if the room doesn't exist or is private.
@@ -61,6 +88,8 @@ async def fetch(self, id: int, include: int = 0) -> 'Room':
6188 :param include: An integer that add additional information to the response.
6289 :return: An room object representing the data.
6390 """
91+ if isinstance (include , list ):
92+ include = sum_enum_list (include )
6493 data : 'Response[RoomResponse]' = await self .rec_net .rooms .rooms (id ).make_request ('get' , params = {'include' : include })
6594 if data .data : return self .create_dataclass (data .data ['RoomId' ], data .data )
6695 return None
0 commit comments