-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
30 lines (27 loc) · 869 Bytes
/
test.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
import time
import os
from pythorhead import Lemmy
from dotenv import load_dotenv
import json
load_dotenv()
lemmy = None
if os.environ['LEMMY_INSTANCE']:
lemmy = Lemmy(f"https://{os.environ['LEMMY_INSTANCE']}", request_timeout=5)
lemmy.log_in(os.environ['LEMMY_USERNAME'], os.environ['LEMMY_PASSWORD'])
def start_loop():
while True:
time.sleep(1)
mentions = lemmy.mention.list(
unread_only=True,
limit=10
)
for mention in mentions['mentions']:
lemmy.comment.create(
post_id = mention['comment']['post_id'],
content = "Cheers",
parent_id = mention['person_mention']['comment_id'],
)
break
start_loop()
# d = lemmy.image.upload('/home/db0/Pictures/SD_INPUTS/logo.png')
# print(json.dumps(d, indent=4))