From 75f6c05d7e793cc333132546e6920f28a5effd3c Mon Sep 17 00:00:00 2001 From: PokestarFan Date: Mon, 11 Sep 2017 18:31:31 -0400 Subject: [PATCH] Move utilities --- Utilities/delete.py => delete.py | 0 Utilities/goodbadbot.py => goodbadbot.py | 0 lowpostremover.py | 83 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+) rename Utilities/delete.py => delete.py (100%) rename Utilities/goodbadbot.py => goodbadbot.py (100%) create mode 100644 lowpostremover.py diff --git a/Utilities/delete.py b/delete.py similarity index 100% rename from Utilities/delete.py rename to delete.py diff --git a/Utilities/goodbadbot.py b/goodbadbot.py similarity index 100% rename from Utilities/goodbadbot.py rename to goodbadbot.py diff --git a/lowpostremover.py b/lowpostremover.py new file mode 100644 index 0000000..85a2c9b --- /dev/null +++ b/lowpostremover.py @@ -0,0 +1,83 @@ +#Bot to remove any submissions by the user that have negative scores +#Created for /u/Pokestarfan +#Created by reddit /u/dustonwithano +#Please PM me on reddit with any issues + +########################### +# import modules +########################### + +import time +import praw +from login import reddit as r + +########################### +# definitions +########################### + +#defining the log in process +global r + +#definig the value: CREATED BY POKESTARFAN AFTER RECIVIAL +setvalue = 1 + +#defining the searching and removal +def action(): + global submission_titles #making global submission title list + global comment_submissions #making glocal comment submission title list + comment_submissions = [] + submission_titles = [] + submission_number = 0 + comment_number = 0 + current_submission_number = 0 + current_comment_number = 0 + print('Searching...') + user = r.user.me() + for submission in r.redditor(str(user)).submissions.new(limit=None): #scanning all submissions by reddit user without limit + if submission.score < setvalue: #if statement checking the submission score < 0 + submission.delete() #deleting the submission + submission_titles.append(submission.title) #adding the submission title to the list + for comment in r.redditor(str(user)).comments.new(limit=None): #scanning all comments by reddit user without limit + if comment.score < setvalue: #if statement checking the comment score < 0 + comment.delete() #deleteing the comment if < 0 + comment_submissions.append(comment.submission.title) #adding the comment's original submission title to the list + +#defining the outputs +def print_results(): + print('Search Complete') + print('--------------------------------------------------') + #if statement. True if there is 1 or more submissions removed. + if len(submission_titles) > 0: + #printing true results + print('Removed ' + str(len(submission_titles)) + ' submission(s).') + print('Submission title(s) include: ') + print(*submission_titles, sep='\n') #printing submission titles with line breaks + print('--------------------------------------------------') + else: + #printing false results + print('No submissions removed.') + print('--------------------------------------------------') + #if statement. True if there is 1 or more comments removed. + if len(comment_submissions) > 0: + #printing true results + print('Removed ' + str(len(comment_submissions)) + ' comment(s).') + print('Comments were under the following submissions: ') + print(*comment_submissions, sep='\n') #printing comment's submission's titles with line breaks + print('--------------------------------------------------') + else: + #printing false results + print('No comments removed.') + print('--------------------------------------------------') + +########################### +# code execution +########################### + + +def main(): + action() + print_results() + +while True: + main() + time.sleep(600) \ No newline at end of file