Advertisement
Guest User

Untitled

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