Advertisement
Guest User

Untitled

a guest
Mar 30th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. # rowanbot
  2.  
  3. import praw
  4. from PyDictionary import PyDictionary
  5. import enchant
  6.  
  7. # reddit api
  8. reddit = praw.Reddit(client_id='XXX',
  9. client_secret='XXX',
  10. username='XXX',
  11. password='XXX',
  12. user_agent='/r/RowanUniversity bot by /u/mcgintyj1')
  13.  
  14. print(reddit.read_only)
  15.  
  16. # subreddits
  17. subreddit = reddit.subreddit('RowanUniversity')
  18.  
  19. #activation phrase
  20. keyphrase = '!Rowan '
  21.  
  22. #dictionary and word check
  23. dictionary = PyDictionary()
  24.  
  25. def isWord(word):
  26. return d.check(word)
  27.  
  28. # what to reply to
  29. for comment in subreddit.stream.comments():
  30. if keyphrase in comment.body:
  31. word = comment.body.replace(keyphrase, '')
  32. try:
  33. if isWord(word):
  34. # defintion
  35. words = dictionary.meaning(word)
  36. reply = [item[0] for item in words.values()]
  37. comment.reply(word + ': ' + reply[0])
  38. print('posted')
  39. else:
  40. reply = 'This is not a word.'
  41. comment.reply(reply)
  42. print('posted')
  43. except:
  44. print('to frequent')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement