🗝
summary refs log tree commit diff
path: root/conf_mia.py
diff options
context:
space:
mode:
authormia <mia@mia.jetzt>2024-10-04 15:43:40 -0700
committermia <mia@mia.jetzt>2024-10-04 15:43:40 -0700
commit7e060e5cf2656a0a53d41ea0ff42b753316cd441 (patch)
tree2629f3d1e12d21c406974000dd195518aa5b6041 /conf_mia.py
parentbb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2 (diff)
downloadscrubber-7e060e5cf2656a0a53d41ea0ff42b753316cd441.tar.gz
scrubber-7e060e5cf2656a0a53d41ea0ff42b753316cd441.zip
she's goin
Diffstat (limited to 'conf_mia.py')
-rw-r--r--conf_mia.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/conf_mia.py b/conf_mia.py
index 6496e3b..a32255f 100644
--- a/conf_mia.py
+++ b/conf_mia.py
@@ -1,18 +1,18 @@
 import math
 from datetime import UTC, datetime, timedelta
 
-from com import FilterableNote, Visibility
+from com import FilterableNote, Visibility, FilterAction
 from sec import connect, tokens
 
 user_id = "9gf2ev4ex5dflllo"
 token = tokens["mia"]
-api = "https://void.rehab/api/"
+api = "https://void.rehab/api"
 early_exit = 0xFFF
 
 now = datetime.now(UTC)
 threshold = 0.1
 
-def criteria(root: FilterableNote) -> bool:
+def criteria(root: FilterableNote) -> FilterAction:
     thread = root.thread()
     thread_self = root.thread_self()
 
@@ -24,13 +24,13 @@ def criteria(root: FilterableNote) -> bool:
         # ...and the dms are younger than two months...
         if now - most_recent_direct.when < timedelta(days=30 * 2):
             # ...do not delete the thread
-            return False
+            return FilterAction.Ignore
 
     # get the most recent post...
     others_recency = max(thread, key=lambda note: note.when)
     # ...and bail if it's too new
     if now - others_recency.when < timedelta(days=14):
-        return False
+        return FilterAction.Ignore
 
     # get my...
     most_recent_post = max(thread_self, key=lambda note: note.when) # ...most recent post...
@@ -43,4 +43,13 @@ def criteria(root: FilterableNote) -> bool:
     # ...weigh it...
     weighted_score = high_score / math.sqrt(most_recent_age.days)
     # ...and check it against a threshold
-    return weighted_score < threshold
+    if weighted_score < threshold:
+        if any(map(
+            lambda note: note.visibility in [Visibility.public, Visibility.unlisted],
+            thread_self,
+        )):
+            return FilterAction.Obliterate
+        else:
+            return FilterAction.Delete
+    else:
+        return FilterAction.Ignore