IPchangeNG/chatgtp.py

23 lines
708 B
Python

import json
IP_HISTORY_FILE = "tu_ruta_a_ip_history.json" # Asegúrate de definir la ruta correcta
def remove_duplicates_preserve_order(history):
"""Elimina duplicados de la lista manteniendo el orden."""
seen = set()
new_history = []
for item in history:
if item not in seen:
seen.add(item)
new_history.append(item)
return new_history
if os.path.exists(IP_HISTORY_FILE):
with open(IP_HISTORY_FILE, "r") as file:
ip_history = json.load(file)
ip_history = remove_duplicates_preserve_order(ip_history)
# Guardar la lista actualizada en el archivo JSON
with open(IP_HISTORY_FILE, "w") as file:
json.dump(ip_history, file)