Skip to content

Instantly share code, notes, and snippets.

@eclecticmiraclecat
Created July 6, 2015 03:52
Show Gist options
  • Save eclecticmiraclecat/8e24aa7c54e0a99d4c0d to your computer and use it in GitHub Desktop.
Save eclecticmiraclecat/8e24aa7c54e0a99d4c0d to your computer and use it in GitHub Desktop.
make the world a beautiful place
#!/usr/bin/python
import praw
import pdb
import re
import os
import time
user_agent = ("spread kindness /u/eclecticmiraclecat13")
r = praw.Reddit(user_agent=user_agent)
r.login('eclecticmiraclecat','password')
msg = "You are an incredibly amazing and an awesome person. If you see someone without a smile, give them one of yours :)"
subs = ['gonewild', 'r4r', 'KindVoice', 'MMFB', 'FreeCompliments', 'Needafriend', 'funny', 'aww']
for i in subs:
subreddit = r.get_subreddit(i)
for submission in subreddit.get_hot(limit=200):
if str(submission.author) not in open('users_replied_to.txt').read():
# get the title from the link
title = ''.join(submission.permalink.split("/")[-2:-1])
authorname = submission.author
r.send_message(authorname, title, msg)
print title
# convert reddit list to str
mystr = ''.join(str(submission.author)).replace("Redditor", "").replace('user_name=', '').replace('(', '').replace(')', '').replace('\'', '').split(",")
q = "".join(mystr)
with open("users_replied_to.txt", "a") as f:
f.write(q + '\n')
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment