-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathredbot.py
31 lines (24 loc) · 812 Bytes
/
redbot.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
import praw
import time
import pickle
class redditbot():
def __init__(self):
self.reddit = praw.Reddit(
client_id="YOUR_CLIENT_ID", #length=14
client_secret="YOIR_CLIENT_SECRET", #lenght=27
user_agent="<name> by /u/<username>", #fill in name nd username in same fashion
username="YOUR_USERNAMAE",
password="YOUR_PASSWORD"
)
print(self.reddit.read_only) # Output: False
print(self.reddit.user.me()) # your username
def submit(self,session):
subreddits,link,title = session['s'], session['l'], session['t']
subreddits = list(subreddits.split(','))
print('bot posting start!!')
# post stuff
self.reddit.validate_on_submit = True
for subred in subreddits:
self.reddit.subreddit(subred).submit(title=title, url=link)
time.sleep(0.1)
time.sleep(1)