This repository was archived by the owner on Oct 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
44 lines (41 loc) · 1.95 KB
/
Copy pathbot.py
File metadata and controls
44 lines (41 loc) · 1.95 KB
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
import praw, prawcore
import getpass
pw = getpass.getpass()
# Replace with real values
reddit = praw.Reddit(user_agent="XXX", client_id="XXX", client_secret="XXX", username="XXX", password=pw)
count = 0
while True:
try:
for i in reddit.subreddit("circleoftrust").stream.submissions():
outputs = []
output = []
key = ""
if not i.title.startswith("u/") and i.link_flair_text != "Betrayed": # " ".join(i.title.split()[:2]),
for j in [i.title]+([i.title.split()[0], i.title.split()[-1]] if len(i.title.split()) > 1 else [])+([" ".join(i.title.split()[-2:])] if len(i.title.split()) > 3 else []):
if not j:
continue
try:
output = reddit.post("/api/guess_voting_key.json", data=dict(id=i.name, raw_json=1, vote_key=j))
outputs.append(output)
if output.get(j):
key = j
break
except prawcore.exceptions.NotFound:
continue
with open("circles.txt", "a") as f:
f.write(i.title + ": " + str(outputs) + "\n")
if output.get(key):
print(f"Got one: {key}")
try:
with open("joinable_circles.txt", "a") as f:
f.write(f"https://www.reddit.com/user/{i.author}/circle/embed\n")
vote = reddit.post("/api/circle_vote.json", data=dict(id=i.name, dir=1, isTrusted=True), params=dict(dir=1, id=i.name))
except Exception as e:
print(f"Error: {str(e)}")
count += 1
if count % 25 == 0:
print(count)
except KeyboardInterrupt:
break
except:
pass