-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdownvotes.py
36 lines (29 loc) · 919 Bytes
/
downvotes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python3
import requests
import json
import sys
import string
from pythorhead import Lemmy
from pythorhead.types import SortType,ListingType
def run(lemmy, live):
threshold = -5 # posts below this score will be flagged
try:
mposts = lemmy.post.list(sort=SortType.New, type_=ListingType.ModeratorView, limit=10)
except Exception as e:
print(f'cannot get moderator posts: {e}\n')
posts = mposts
for p in posts:
if ('hidden' not in p) or (p['hidden'] is True):
break
if p['counts']['score'] < threshold:
if live:
try:
lemmy.report(p["post"]["id"], f'Downvoted - Score {p["counts"]["score"]}') # raise report
except Exception as e:
print("unable to raise report: {e}")
return
try:
lemmy.post.hide(p["post"]["id"], True)
except Exception as e:
print(f'cannot hide post: {e}\n')
return