From cbdbefb5fc10ad3b6c7311bd259db020e8f524c5 Mon Sep 17 00:00:00 2001
From: w <waifuism@tutanota.com>
Date: Tue, 3 Jun 2025 23:08:15 -0300
Subject: [PATCH] weight add_character change

---
 bot/add_character.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/bot/add_character.py b/bot/add_character.py
index e8d078b..18b0f98 100644
--- a/bot/add_character.py
+++ b/bot/add_character.py
@@ -3,12 +3,12 @@ from misskey.exceptions import MisskeyAPIException
 from client import client_connection
 from db_utils import insert_character
 from custom_types import Character
+from config import RARITY_TO_WEIGHT
 
 
 def add_character(
         name: str,
         rarity: int,
-        weight: float,
         image_url: str) -> tuple[int, str]:
     '''
     Adds a character to the database, uploading the image from a public URL to
@@ -17,7 +17,6 @@ def add_character(
     Args:
         name (str): Character name.
         rarity (int): Character rarity (e.g., 1-5).
-        weight (float): Pull weight (e.g., 0.02).
         image_url (str): Public URL of the image from the post (e.g., from
             note['files'][i]['url']).
 
@@ -36,8 +35,8 @@ def add_character(
         raise ValueError('Character name cannot be empty.')
     if rarity < 1:
         raise ValueError('Rarity must be a positive integer.')
-    if weight <= 0:
-        raise ValueError('Weight must be a positive number.')
+    if rarity not in RARITY_TO_WEIGHT.keys():
+        raise ValueError(f'Invalid rarity: {rarity}')
     if not image_url:
         raise ValueError('Image URL must be provided.')
 
@@ -59,7 +58,7 @@ def add_character(
     character_id = insert_character(
             stripped_name,
             rarity,
-            float(weight),
+            RARITY_TO_WEIGHT[rarity],
             file_id
     )
     return character_id, file_id