feat(tasklist): Show tasklists in private rooms.

Also adds a `get_rooms` method to the `RoomCog`.
This commit is contained in:
2023-09-11 15:16:19 +03:00
parent 8e54186649
commit 494484fc3c
3 changed files with 27 additions and 2 deletions

View File

@@ -57,6 +57,21 @@ class RoomCog(LionCog):
for task in self._ticker_tasks.values():
task.cancel()
def get_rooms(self, guildid: int, userid: Optional[int] = None):
"""
Get the private rooms in the given guild, using cache.
If `userid` is provided, filters by rooms which the given user is a member or owner of.
"""
guild_rooms = self._room_cache[guildid]
if userid:
rooms = {
cid: room for cid, room in guild_rooms.items() if userid in room.members or userid == room.data.ownerid
}
else:
rooms = guild_rooms
return rooms
async def _prepare_rooms(self, room_data: list[RoomData.Room]):
"""
Launch or destroy rooms from the provided room data.