blezz-tech hace 1 día
padre
commit
18f7b6c1cb
Se han modificado 1 ficheros con 10 adiciones y 6 borrados
  1. 10 6
      lib/seed.py

+ 10 - 6
lib/seed.py

@@ -9,12 +9,16 @@ def create_api_key_for_handlers():
     api_key_list = []
 
     for botname in BOTLIST:
-        if not APIKey.objects.filter(name=f"api-key-for-{botname}").exists():
-            api_key, key = APIKey.objects.create_key(name=f"api-key-for-{botname}")
-            api_key_list.append([botname, key])
-            print(f"Initial API Key for {botname} handler created.")
-        else:
-            print(f"Initial API Key for {botname} handler already exists.")
+        keys_to_revoke = APIKey.objects.filter(name="botname", revoked=False)
+
+        # Отзываем каждый ключ
+        for key in keys_to_revoke:
+            key.revoked = True
+            key.save()
+
+        api_key, key = APIKey.objects.create_key(name=botname)
+        api_key_list.append([botname, key])
+        print(f"Initial API Key for {botname} handler created.")
 
     api_key_list = list(map(lambda x: x[0] + '_key=' + x[1], api_key_list))
     txt = '\n'.join(api_key_list)