Skip to content

Instantly share code, notes, and snippets.

@j-mcc1993
Last active June 26, 2020 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-mcc1993/694917ca74b254b56eef4560ff0d9eea to your computer and use it in GitHub Desktop.
Save j-mcc1993/694917ca74b254b56eef4560ff0d9eea to your computer and use it in GitHub Desktop.
A reddit bot that crawls r/ucsd looking for posts about Gary Gillespie.
#!/usr/local/bin/python3.5
import praw
import random
# Delicious Memes
memes = [
"""Gary "The Transfer Crusher" Gillespie\n\nGary "Caught A Scrub on
Github" Gillespie\n\nGary "The Great Wall Of CS" Gillespie\n\nGary
"Bitches Don't Know About My Wine App" Gillespie\n\nGary "Be Scared If
You're Undeclared" Gillespie\n\nGary "Your Grade On The Final Will Make
You Homicidal" Gillespie\n\nGary "Another Pleb Caught in My Web"
Gillespie\n\nGary "You Will Be Sore By Homework 4"
Gillespie\n\nGary "My HashTable Makes Plebs Disabled"
Gillespie\n\nGary "Unloading My Nine At The Scrub Line"
Gillespie\n\nGary "Amused If You're Confused"
Gillespie\n\nGary "Weekend Off? Not On My Watch"
Gillespie\n\nGary "You Will Regret Stealing Code From The Internet"
Gillespie\n\nGary "No Mercy For The Unworthy"
Gillespie\n\nGary "Professionalism Cataclysm" Gillespie""",
"""As announced at the final exam, the grade breakdown will be posted on
Piazza early this\nweek. I also announced that my deadline to submit grades
is Tuesday. Asking about the\ncourse graded before the grade deadline is
like me asking for your programming submission\nbefore the assignment
deadline. However much the question is asked, however much you want\nknow
the information, however much I want to know the information, when the
information is\nstill unknown, there is no answer to the question. I'm not
in the situation where I know\nthe answer to your question and am
withholding it from you.\nReading and responding to your question about the
course grade breakdown before the\ninformation is known just causes the
very information you seek to be delayed for everyone\nsince I'm taking the
time to respond to you instead of continuing with the analysis needed\nto
determine the course grades. After being at the CSE 12 final exam until
after 10pm on\nFriday night and after spending all day Saturday grading
final exams until after 6pm, any\nquestions about your course grades asked
Saturday or Sunday show no consideration to me or\nto the course staff in
allowing a day of rest or a reasonable amount of time to pass\nbefore
expecting the course grade to be determined. You've waited more than 10
weeks to\nknow your grade in this course. Can't you wait a few more days
before demonstrating\nyour impatience?\nAs the student replier indicated,
your question is worthy of a professionalism deduction.\nKnowing the
answer to your question benefits no one, not even you. Knowing now
doesn't\nchange your grade, and it doesn't provide insights into the
course content. Specifically,\nyour question is an example of interactions
to avoid such as "asking questions where the\ninformation will eventually
be known."\nAt the beginning of the course, we awarded you 100% for the
professionalism portion of\nyour course grade assuming that all
interactions would be professional. Your interaction\nabove indicates that
our initial prediction of your professionalism was incorrect.I've\nmade an
adjustment in your score to reflect the error in our assumptions.\nIf
you'd like to explain how your question above demonstrates consideration,
patience, and\nprofessionalism, please let me know.""",
"http://i.imgur.com/P7Z6Ogv.png",
"https://i.redd.it/4dqukg50qxiy.jpg"
]
# Terms to search for
keywords = ['gary', 'gillespie']
# Connect to Reddit and identify script
my_user_agent = 'GaryMemeBot v1.0 by /u/I_Am_Treebeard'
# Get reddit instance
print('Getting reddit instance...')
r = praw.Reddit(client_id = 'q9GsFF8BBFeCGg',
client_secret = 'ZjppktTCeJlyNVkQ7byVRLAii2Q',
user_agent = my_user_agent,
username = 'GARY_MEMES_BOT',
password = REDACTED)
print('Done.')
subreddit = r.subreddit('ucsd')
# Iterate over recent submissions
for submission in subreddit.hot(limit = 50):
title = submission.title.lower()
if any(word in title for word in keywords):
print('Found a Gary post!')
print("Title: " + submission.title)
# Check if we've already commented on this submission
visited = False
for comment in submission.comments.list():
if comment.author == "GARY_MEMES_BOT":
print('Already commented!')
visited = True
# If not, post meme
if not visited:
index = random.randint(0,3)
print('Commenting meme...')
submission.reply(memes[index])
print('Done.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment