-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposter.py
More file actions
executable file
·98 lines (86 loc) · 2.43 KB
/
Copy pathposter.py
File metadata and controls
executable file
·98 lines (86 loc) · 2.43 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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /usr/bin/env python3
# pylint: disable=missing-module-docstring,missing-function-docstring,invalid-name,no-member,unused-argument,unused-variable,missing-class-docstring,line-too-long
import os
import random
import sys
import praw
def main():
try:
clientid = os.environ["REDDIT_CLIENT_ID"]
clientsecret = os.environ["REDDIT_CLIENT_SECRET"]
username = os.environ["REDDIT_USERNAME"]
password = os.environ["REDDIT_PASSWORD"]
except KeyError:
sys.exit(1)
reddit = praw.Reddit(
client_id=clientid,
client_secret=clientsecret,
user_agent=os.environ.get("REDDIT_USER_AGENT", "redditwipe"),
username=username,
password=password,
)
x = random.randint(1, 4)
if x == 1:
submissions = list(reddit.redditor(username).submissions.new(limit=None))
if not submissions:
print("No submissions found, skipping reply.", file=sys.stderr)
return
try:
random.choice(submissions).reply(Random_words())
except Exception as e:
print(
"got an error replying to an existing submission. [{}]".format(str(e)),
file=sys.stderr,
)
elif x == 2:
comments = list(reddit.redditor(username).comments.new(limit=None))
if not comments:
print("No comments found, skipping reply.", file=sys.stderr)
return
try:
random.choice(comments).reply(Random_words())
except Exception as e:
print(
"got an error replying to an existing comment. [{}]".format(str(e)),
file=sys.stderr,
)
else:
try:
reddit.subreddit("reddit_api_test").submit(Random_words(), selftext=Random_words())
except Exception as e:
print(
"got an error making a new submission. [{}]".format(str(e)),
file=sys.stderr,
)
phonetic = [
"alfa",
"bravo",
"charlie",
"delta",
"echo",
"foxtrot",
"golf",
"hotel",
"india",
"juliet",
"kilo",
"lima",
"mike",
"november",
"oscar",
"papa",
"quebec",
"romeo",
"sierra",
"tango",
"uniform",
"victor",
"whiskey",
"x-ray",
"yankee",
"zulu",
]
def Random_words():
return " ".join(random.choices(phonetic, k=random.randint(3, 8)))
if __name__ == "__main__":
main()