Advertisement
Guest User

Untitled

a guest
Aug 7th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. import json, requests, time, praw, getpass, random, string
  2.  
  3. user = raw_input("Username: ")
  4.  
  5. redd = praw.Reddit(client_id='',  # Reddit's ID for your application
  6.                    client_secret='', # Reddit's secret key for that application
  7.                    user_agent='', # Can be whatever you want
  8.                    username=user,
  9.                    password=getpass.getpass())
  10.  
  11. keep_history = 5
  12.  
  13. me = redd.redditor(user)
  14.  
  15.  
  16. def show_comments(acct):
  17.     comments = acct.comments.new(limit=None)
  18.     comments = list(reversed(list(comments)))
  19.     print("Found total of: " + str(len(comments)) + " comments.")
  20.  
  21.     first_com = comments[0].body.split('\n', 1)[0][:79]
  22.     last_com = comments[(len(comments) - keep_history)].body.split('\n', 1)[0][:79]
  23.     print("First to be deleted: \n\n" + str(first_com))
  24.     print("Last to be deleted: \n\n" + str(last_com))
  25.  
  26. def bunkify_old_comments(acct):
  27.     comments = acct.comments.new(limit=None)
  28.     comments = list(reversed(list(comments)))
  29.     print("Found total of: " + str(len(comments)) + " comments.")
  30.  
  31.     for i in range((len(comments) - keep_history)):
  32.       rand = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(2096)])
  33.       print("Attempting to edit comment with " + str(rand))
  34.       comments[i].edit(rand)
  35.  
  36. def delete_old_comments(acct):
  37.     comments = acct.comments.new(limit=None)
  38.     comments = list(reversed(list(comments)))
  39.     print("Found total of: " + str(len(comments)) + " comments.")
  40.  
  41.     for i in range((len(comments) - keep_history)):
  42.       print("Attempting to delete comment... " + str(comments[i].fullname))
  43.       comments[i].delete()
  44.  
  45. def repeat_bunkify(num, sleep):
  46.     print("Repeating edits " + str(num) + " times.\n")
  47.     for i in range(1, num):
  48.         print("Executing cycle " + str(i) + " out of " + str(num) + ".\n")
  49.         bunkify_old_comments(me)
  50.         print("Sleeping for " + str(sleep) + " seconds...")
  51.         tenth = sleep / 10
  52.         total_slept = 0
  53.         for i in range(1, 10):
  54.             time.sleep(tenth)
  55.             cycles_remain = 10 - i
  56.             secs_remain = cycles_remain * tenth
  57.             print("... " + str(secs_remain) + " seconds left in sleep...")
  58.  
  59.  
  60. def full_cycle(cycles, sleep):
  61.     repeat_bunkify(cycles, sleep)
  62.     delete_old_comments(me)
  63.  
  64. #show_comments(me)
  65.  
  66. full_cycle(500, 1270)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement