Advertisement
Guest User

Untitled

a guest
May 4th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.60 KB | None | 0 0
  1. import praw
  2.  
  3. r = praw.Reddit('/u/AbleismBot scanning the SRS Fempire for people using ableist words, and posting replies correcting them.')
  4. r.login('AbleismBot', censored)
  5.  
  6. srsMultiOne = r.get_subreddit('shitredditsays+srsmeta+srsdiscussion+srsmailbag+srsredditdrama+srsgreatesthits+goldredditsays+socialjustice101+srsanarchists+srsbusiness+srsfunny+srshappy+srsimages+srsquestions+srszone+srsaustralia+srsbeliefs+srsbisexual+srsbodytalk+srscanada+srsdeaf+srsdharma+srsdisabilities+srsgsm+srskink+srsmen+srspoc+srsrecovering+srssex+srsskeptic+srssocialism+srstranssupport+srswomen+srsfeminism+srsivorytower+srsnews+srspolitics+srsscience+srstechnology+fitnessplus+srsasoiaf+srsbooks+srsbooze+srscomics+srscycles+srsdramaticreadings+srsfoodies+srsgaming+srsgifs+srsliberty')
  7. srsMultiOneComments = srsMultiOne.get_comments()
  8. srsMultiTwo = r.get_subreddit('srslinux+srsmotorcycles+srsmusicals+srspets+srsponies+srsprogramming+srstrees+srstumblr+daww+scifiandfantasy+srsart+srsauthors+srscinema+srsfartsandcrafts+srsmusic+srspoetry+srstelevision')
  9. srsMultiTwoComments = srsMultiTwo.get_comments()
  10. ableistWords = [
  11.     " blind to ",
  12.     " turn a blind eye ",
  13.     " blinded by ",
  14.     " crazy ",
  15.     " cretin ",
  16.     " crippled ",
  17.     " daft ",
  18.     " derp ",
  19.     " herp ",
  20.     " dumb ",
  21.     " harelip ",
  22.     " idiotic ",
  23.     " idiot ",
  24.     " imbecile ",
  25.     " insanity ",
  26.     " insane ",
  27.     " invalid ",
  28.     " lame ",
  29.     " lunatic ",
  30.     " loony ",
  31.     " madhouse ",
  32.     " madman ",
  33.     " maniac ",
  34.     " mental case ",
  35.     " mongoloid ",
  36.     " nuts ",
  37.     " psychopathic ",
  38.     " psychopath ",
  39.     " psychotic ",
  40.     " psycho ",
  41.     " retarded ",
  42.     " retard ",
  43.     " tard ",
  44.     " short-bus ",
  45.     " short bus ",
  46.     " simpleton ",
  47.     " spazzed ",
  48.     " spaz ",
  49.     " stupid ",
  50.     " wacko ",
  51.     " whacko "
  52. ]
  53.  
  54. def processComment(comment):
  55.     commentText = comment.body.lower()
  56.     detectedSlurs = [slur.strip() for slur in ableistWords if slur in commentText]
  57.     permlink = comment.permalink
  58.     repliedComments = list(set(open('ableismbotrepliedcomments.txt').read().split("\n")))
  59.     notInList = permlink in repliedComments
  60.    
  61.     if (len(detectedSlurs) > 0) and ((str)(comment.author) != "AbleismBot") and not permlink in repliedComments:
  62.         replyString = "/u/AbleismBot detected the following ableist words in your comment:\n\n"
  63.        
  64.         for slur in detectedSlurs:
  65.             replyString += "* " + slur + "\n\n"
  66.  
  67.         replyString += "For a list of ableist words and their substitutes, go [here.](http://www.autistichoya.com/p/ableist-words-and-terms-to-avoid.html)\n\nThis bot cannot see context, so if you were quoting somebody else, or if you were not using these words in an ableist manner, reply with \"delete\".\n\nBot maintained by /u/Wyboth."
  68.  
  69.         try:
  70.             comment.reply(replyString)
  71.             writetofile = open("ableismbotrepliedcomments.txt", "a")
  72.             writetofile.write(permlink + "\n")
  73.             writetofile.close()
  74.         except:
  75.             print "Reply failed."
  76.  
  77. for comment in srsMultiOneComments:
  78.     processComment(comment)
  79. for comment in srsMultiTwoComments:
  80.     processComment(comment)
  81.  
  82. messages = r.get_inbox()
  83.  
  84. for message in messages:
  85.     if message.was_comment and ("delete" in message.body.lower()):
  86.         parent = r.get_info(thing_id=message.parent_id)
  87.         grandparent = r.get_info(thing_id=parent.parent_id)
  88.         if (str)(grandparent.author) == (str)(message.author):
  89.             try:
  90.                 parent.delete()
  91.             except:
  92.                 print "Couldn't delete.\n"
  93.  
  94. print "Program complete."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement