-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownvotes.py
executable file
·46 lines (38 loc) · 1.19 KB
/
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
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python3
import requests
import json
import sys
import string
import firestore
from pythorhead import Lemmy
from pythorhead.types import SortType,ListingType
def run(lemmy, live):
threshold = -5 # posts below this score will be flagged
# add additional communities here and uncomment the + cposts below
#cid = lemmy.discover_community("imaginaryfairies@lemmings.world")
#
#try:
# cposts = lemmy.post.list(cid, sort=SortType.New, limit=10)
#except Exception as e:
# print(f'cannot get posts: {e}\n')
# sys.exit(1)
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 #+ cposts
for p in posts:
if 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