diff options
author | mia <mia@mia.jetzt> | 2024-09-04 04:47:13 -0700 |
---|---|---|
committer | mia <mia@mia.jetzt> | 2024-09-04 04:47:13 -0700 |
commit | bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2 (patch) | |
tree | bdb0654c667f37c69addc9efd1e29b9cfe710c51 /conf_mia.py | |
parent | 81071e8feefdf815e29318226c668664e1706da2 (diff) | |
download | scrubber-bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2.tar.gz scrubber-bb8a48fd4d85ba4f8224c68aaaf9069d5d79dae2.zip |
desktop changes
Diffstat (limited to 'conf_mia.py')
-rw-r--r-- | conf_mia.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/conf_mia.py b/conf_mia.py new file mode 100644 index 0000000..6496e3b --- /dev/null +++ b/conf_mia.py @@ -0,0 +1,46 @@ +import math +from datetime import UTC, datetime, timedelta + +from com import FilterableNote, Visibility +from sec import connect, tokens + +user_id = "9gf2ev4ex5dflllo" +token = tokens["mia"] +api = "https://void.rehab/api/" +early_exit = 0xFFF + +now = datetime.now(UTC) +threshold = 0.1 + +def criteria(root: FilterableNote) -> bool: + thread = root.thread() + thread_self = root.thread_self() + + # if there are dms involved... + low_vis = min(thread, key=lambda note: note.visibility.value) + if low_vis.visibility == Visibility.direct: + is_direct = lambda note: note.visibility == Visibility.direct + most_recent_direct = max(filter(is_direct, thread), key=lambda note: note.when) + # ...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 + + # 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 + + # get my... + most_recent_post = max(thread_self, key=lambda note: note.when) # ...most recent post... + score = lambda note: note.reactions + note.renotes*5 + high_score_post = max(thread_self, key=score) # ...highest scoring post... + # ...and their values... + most_recent = most_recent_post.when + most_recent_age = now - most_recent + high_score = score(high_score_post) + # ...weigh it... + weighted_score = high_score / math.sqrt(most_recent_age.days) + # ...and check it against a threshold + return weighted_score < threshold |