From 8fd3bf065154ae50ce61cde6d6a67c45a05f6b25 Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Tue, 16 Apr 2024 04:23:22 +0200 Subject: [PATCH] initial get_roles util function --- bot/src/cogs/galtinn.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bot/src/cogs/galtinn.py b/bot/src/cogs/galtinn.py index 2cd4d39..e194c9c 100644 --- a/bot/src/cogs/galtinn.py +++ b/bot/src/cogs/galtinn.py @@ -117,6 +117,37 @@ class Galtinn(commands.Cog): return galtinn_user["results"][0] + async def get_roles(self, galtinn_user: dict) -> tuple[set, set]: + """ + Get which roles to add and which to remove based on the user's Galtinn membership status + + Parameters + ---------- + galtinn_user (dict): Galtinn user object + + Reuturns + ---------- + tuple[set, set]: Roles to add, roles to remove + """ + + # Fetch roles + roles = set() + + roles_to_add = set() + if galtinn_user["is_member"]: + # roles_to_add.add(member) + pass + if galtinn_user["is_active"]: + # roles_to_add.add(active) + pass + + for org in galtinn_user["organizations"]: + roles_to_add.add(org) + + roles_to_remove = roles - roles_to_add + + return roles_to_add, roles_to_remove + @tasks.loop(time=misc_utils.MIDNIGHT) async def membership_check(self): """