Guest User

Untitled

a guest
May 26th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import praw, enchant
  2. from PyDictionary import PyDictionary
  3.  
  4. reddit = praw.Reddit(
  5. client_id ='jtSGr_Wpj4TlaA',
  6. client_secret ='U1IZmN0jv42-2F6aEVzXKK7XzQM',
  7. username ='spell_bot_20',
  8. password ='nope',
  9. user_agent='spellbot by /u/Relationship_Terry'
  10. )
  11.  
  12. subreddits = reddit.subreddit(
  13. 'test'
  14. )
  15.  
  16. keyword = '!spellbot '
  17.  
  18. dictionary = PyDictionary()
  19. d = enchant.Dict('en_US')
  20.  
  21. def isWord(word):
  22. return d.check(word)
  23.  
  24. for comment in subreddits.stream.comments():
  25. if keyword in comment.body:
  26. word = comment.body.replace(keyword, '')
  27. try:
  28. if isWord(word):
  29. words = dictionary.meaning(word)
  30. reply = [item[0] for item in words.values()]
  31. comment.reply(word + ': this is spelled correctly.')
  32. print('posted')
  33. else:
  34. reply = "Hmm, I don't think that's a word."
  35. comment.reply(reply)
  36. print('posted')
  37. except:
  38. print('wot')
Add Comment
Please, Sign In to add comment