Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import praw
- import time
- import sched
- import sys
- print("""\
- ,|
- / ;
- / |
- : ,'(
- |( `.|
- : \ `\ \.
- \ `. | `.
- \ `-._ ; |
- \ ``-.'.. _ `._
- `. `-. ```-...__
- .'`. --.. ``-..____
- ,'.-'`,_-._ (((( <o. ,'
- `' `-.)``-._-...__```` ____.-'
- ,' _,'.--,---------'
- _.-' _..-' ),'
- ``--'' `
- SHARK REDDIT POSTER BOT """)
- sh = sched.scheduler(time.time, time.sleep)
- data = json.load(open("subs.json"))
- with open('backup.json', 'w') as outfile:
- json.dump(data, outfile)
- print("subs loaded from subs.json")
- def do_something(sc):
- try:
- print "Start Posting..."
- submissions = []
- for s in data:
- from time import sleep
- from threading import Thread
- reddit = praw.Reddit(client_id='myclientid', client_secret="myclientsecret",
- password='mypassword', user_agent='myredditusername',
- username='myredditusername')
- reddit.subreddit(s["subreddit"]).submit(s["title"], s["text"])
- del data[0]
- with open('subs.json', 'w') as outfile:
- json.dump(data, outfile)
- print "posted" + s["title"] +"successfully"
- except:
- print "error...retry - maybe timelimit of 9 minutes posting...dont worry :)"
- sh.enter(600,1, do_something, (sc,))
- sh.enter(10, 1, do_something, (sh,))
- sh.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement