-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfus.py
69 lines (51 loc) · 2.33 KB
/
fus.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests
from datetime import datetime, timezone, timedelta
def repost_fus(session):
now = datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
date_lst = (datetime.now(timezone.utc) - timedelta(hours=1)).isoformat().replace("+00:00", "Z").split(':')
date_lst[1] = ':33:'
one_hour_ago = ''.join(date_lst)
request_header = {"Authorization": "Bearer " + session["accessJwt"]}
# how ther fuyck do u search with boolean operators in this thing
posts_fus = requests.get('https://bsky.social/xrpc/app.bsky.feed.searchPosts',
headers = request_header,
params={"q": "fus", 'since': one_hour_ago}
).json()
#posts_fuss = requests.get('https://bsky.social/xrpc/app.bsky.feed.searchPosts',
# headers = request_header,
# params={"q": "fuss", 'since': one_hour_ago}
# ).json()
posts_fusz = requests.get('https://bsky.social/xrpc/app.bsky.feed.searchPosts',
headers = request_header,
params={"q": '"fuß"', 'since': one_hour_ago}
).json()
posts_Fusz = requests.get('https://bsky.social/xrpc/app.bsky.feed.searchPosts',
headers = request_header,
params={"q": '"Fuß"', 'since': one_hour_ago}
).json()
posts = posts_fusz["posts"] + posts_Fusz["posts"] # + posts_fuss["posts"] + posts_fus["posts"]
unique_posts = []
unique_str = ''
for post in posts:
if post['uri'] not in unique_str and not 'fusverbot' in post['author']['handle']:
if 'fuß' in post['record']['text'] or 'Fuß' in post['record']['text']:
unique_posts.append(post)
print(len(unique_posts))
for post in unique_posts:
record = {
"$type": "app.bsky.feed.repost",
"subject": {
"uri": post['uri'],
"cid": post['cid']
},
"createdAt": datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
}
resp = requests.post("https://bsky.social/xrpc/com.atproto.repo.createRecord",
headers = request_header,
json={
"repo": session['did'],
"collection": "app.bsky.feed.repost",
"record": record
}
).json()
print(resp)