Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cat mods.csv
- *******************************************
- resistmod,esist
- 71tsiser,esist
- thefrontofprogress,esist
- Shadowfacts-,esist
- IanDesmondsTutu,esist
- GuyBelowMeDoesntLift,esist
- yzlautum,esist
- 4thepower,esist
- v12a12,esist
- TheBearJulep,esist
- MaximumEffort433,esist
- AgentGarak,esist
- agentjulianbashir,esist
- PostimusMaximus,esist
- BernieSanskrit,esist
- Gsteel11,esist
- gets_it_mountie,marchagainsttrump
- Avenger_of_Justice,marchagainsttrump
- whatwildoes,marchagainsttrump
- Mannos_Hands_of_Fate,marchagainsttrump
- Jar_O_Memes,marchagainsttrump
- awkwardtheturtle,marchagainsttrump
- ChittyBangBangYeah,marchagainsttrump
- order1776,marchagainsttrump
- randoh12,marchagainsttrump
- Llim,marchagainsttrump
- Fabulastrophe,marchagainsttrump
- Goatsac,marchagainsttrump
- nameuser4321,marchagainsttrump
- specification,marchagainsttrump
- Merari01,marchagainsttrump
- TheSentinel_14,marchagainsttrump
- List_on_Somnia,marchagainsttrump
- DanglyW,againsthatesubreddits
- AutoModerator,againsthatesubreddits
- 75000_Tokkul,againsthatesubreddits
- LIATG,againsthatesubreddits
- WorseThanHipster,againsthatesubreddits
- NewJerseyFreakshow,againsthatesubreddits
- DubTeeDub,againsthatesubreddits
- Br00ce,againsthatesubreddits
- siouxsie_siouxv2,againsthatesubreddits
- duckvimes_,againsthatesubreddits
- Zachums,againsthatesubreddits
- awkwardtheturtle,againsthatesubreddits
- Deefian,againsthatesubreddits
- PizzaRollers,againsthatesubreddits
- TheSentinel_14,againsthatesubreddits
- TzHaar-ket-om,againsthatesubreddits
- ******************************************
- cat praw.ini
- ******************************************
- cat praw.ini
- [DEFAULT]
- # A boolean to indicate whether or not to check for package updates.
- check_for_updates=True
- # Object to kind mappings
- comment_kind=t1
- message_kind=t4
- redditor_kind=t2
- submission_kind=t3
- subreddit_kind=t5
- # The URL prefix for OAuth-related requests.
- oauth_url=https://oauth.reddit.com
- # The URL prefix for regular requests.
- reddit_url=https://www.reddit.com
- # The URL prefix for short URLs.
- short_url=https://redd.it
- [HateSubredditBot]
- client_id=changeme
- client_secret=changeme
- password=changeme
- username=changeme
- user_agent=HateSubredditBot v0.2
- ********************************************
- cat HateSubredditBot.py
- ********************************************
- #!/usr/bin/python
- import praw
- import pdb
- import re
- import os
- import csv
- # CHANGEME CHANGEME CHANGEME CHANGEME
- postto_subreddit = "AgainstHateSubreddits"
- # Read mods.csv file format modname,subredditname
- file1reader = csv.reader(open("mods.csv"), delimiter=",")
- # Create the Reddit instance
- reddit = praw.Reddit('HateSubredditBot')
- # Have we run this code before? If not, create an empty list
- if not os.path.isfile("posts_replied_to.txt"):
- posts_replied_to = []
- # If we have run the code before, load the list of posts we have replied to
- else:
- # Read the file into a list and remove any empty values
- with open("posts_replied_to.txt", "r") as f:
- posts_replied_to = f.read()
- posts_replied_to = posts_replied_to.split("\n")
- posts_replied_to = list(filter(None, posts_replied_to))
- # For each user in the file1reader
- for username, subreddit in file1reader:
- user = reddit.redditor(username)
- #Load their most recent 5 comments
- for comment in user.comments.new(limit=5):
- if comment.id not in posts_replied_to:
- # Extract the exact URL to the comment
- comment_url = comment.link_permalink + comment.id
- # Extract the text of the comment (up to 75 characters)
- comment_text = (comment.body[:75] + '..') if len(comment.body) > 75 else comment.body
- # Create the string we will use for the post title
- post_content = "r/"+subreddit+" mod u/" +username+" commented \"" + comment_text + "\""
- # Debugging only
- # print(comment_url)
- # print(post_content)
- # Submit the post to reddit
- reddit.subreddit(postto_subreddit).submit(post_content, url=comment_url)
- # Save in our list that we have posted this comment so we don't do it again
- posts_replied_to.append(comment.id)
- # Write our updated list back to the file
- with open("posts_replied_to.txt", "w") as f:
- for post_id in posts_replied_to:
- f.write(post_id + "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement