Skip to content

Commit

Permalink
Convert more config values to their expected types
Browse files Browse the repository at this point in the history
  • Loading branch information
cromachina committed Mar 29, 2023
1 parent 3414ce4 commit 8d225bf
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,18 @@ def convert_post(post):
, 'tt': 'a16cbb5611d546e8f4f509f9cbdf98b5' # IDK what this is, but it doesn't seem to change. A hash maybe?
}

def map_dict(a, f):
b = {}
for kv in a.items():
k, v = f(*kv)
b[k] = v
return b

def make_roles_objects(plan_roles):
return { k: discord.Object(v) for k, v in plan_roles.items() }
return map_dict(plan_roles, lambda k, v: (str(k), discord.Object(int(v))))

def str_values(d):
return map_dict(d, lambda k, v: (k, str(v)))

def update_rate_limited(user_id, rate_limit, rate_limit_table):
now = time.time()
Expand Down Expand Up @@ -126,6 +136,8 @@ def load_config(config_file):
config.fallback_role = discord.Object(int(config.fallback_role))
config.all_roles = list(config.key_roles.values()) + list(config.plan_roles.values())
config.cleanup = obj(config.cleanup)
config.session_cookies = str_values(config.session_cookies)
config.fantia_session_cookies = str_values(config.fantia_session_cookies)
return config

def load_registry():
Expand Down

0 comments on commit 8d225bf

Please sign in to comment.