Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. import json
  2. import praw
  3. import time
  4. import sched
  5. import sys
  6.  
  7.  
  8. print("""\
  9.      ,|
  10.     / ;
  11.    /  |
  12.   : ,'(
  13.   |( `.|
  14.   : \ `\      \.
  15.    \ `.         | `.
  16.     \ `-._     ;   |
  17.      \    ``-.'.. _ `._
  18.       `. `-.            ```-...__
  19.        .'`.        --..          ``-..____
  20.      ,'.-'`,_-._            ((((   <o.   ,'
  21.           `' `-.)``-._-...__````  ____.-'
  22.               ,'    _,'.--,---------'
  23.           _.-' _..-'   ),'
  24.          ``--''        `
  25.          SHARK REDDIT POSTER BOT """)
  26.  
  27. sh = sched.scheduler(time.time, time.sleep)
  28. data = json.load(open("subs.json"))
  29. with open('backup.json', 'w') as outfile:
  30.     json.dump(data, outfile)
  31. print("subs loaded from subs.json")
  32. def do_something(sc):
  33.     try:
  34.         print "Start Posting..."        
  35.         submissions = []
  36.         for s in data:
  37.                     from time import sleep
  38.                     from threading import Thread
  39.                     reddit = praw.Reddit(client_id='myclientid', client_secret="myclientsecret",
  40.                     password='mypassword', user_agent='myredditusername',
  41.                     username='myredditusername')
  42.                     reddit.subreddit(s["subreddit"]).submit(s["title"], s["text"])
  43.                     del data[0]
  44.                     with open('subs.json', 'w') as outfile:
  45.                         json.dump(data, outfile)
  46.  
  47.         print "posted" + s["title"] +"successfully"            
  48.     except:
  49.         print "error...retry - maybe timelimit of 9 minutes posting...dont worry :)"
  50.                
  51.        
  52.     sh.enter(600,1, do_something, (sc,))  
  53. sh.enter(10, 1, do_something, (sh,))
  54. sh.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement