Public Access
24 lines
865 B
Python
24 lines
865 B
Python
import os
|
|
import json
|
|
import time
|
|
|
|
BASE_DIR = "/DATA/AppData/MULTI-IA-AETHAS38"
|
|
os.makedirs(BASE_DIR, exist_ok=True)
|
|
HISTORY_FILE = os.path.join(BASE_DIR, "aethas_history.json")
|
|
|
|
def load_history():
|
|
if not os.path.exists(HISTORY_FILE):
|
|
with open(HISTORY_FILE, 'w', encoding='utf-8') as f: json.dump({}, f)
|
|
with open(HISTORY_FILE, 'r', encoding='utf-8') as f: return json.load(f)
|
|
|
|
def save_history(history):
|
|
with open(HISTORY_FILE, 'w', encoding='utf-8') as f: json.dump(history, f, indent=4)
|
|
|
|
def nettoyer_vieilles_discussions():
|
|
history = load_history()
|
|
now = time.time()
|
|
un_an = 365 * 24 * 60 * 60
|
|
a_supprimer = [cid for cid, data in history.items() if not data.get('pinned', False) and now - data.get('timestamp', now) > un_an]
|
|
if a_supprimer:
|
|
for cid in a_supprimer: del history[cid]
|
|
save_history(history) |