Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # rowanbot
- import praw
- from PyDictionary import PyDictionary
- import enchant
- # reddit api
- reddit = praw.Reddit(client_id='XXX',
- client_secret='XXX',
- redirect_uri='http://localhost:8080',
- user_agent='/r/RowanUniversity bot by /u/mcgintyj1',
- password='owner',
- username='owner')
- print(reddit.auth.url(['identity'], '...', 'permanent'))
- reddit.auth.authorize(['code'])
- print(reddit.user.me())
- # subreddits
- subreddit = reddit.subreddit('RowanUniversity')
- #activation phrase
- keyphrase = '!Rowan '
- #dictionary and word check
- dictionary = PyDictionary()
- def isWord(word):
- return d.check(word)
- # what to reply to
- for comment in subreddit.stream.comments():
- if keyphrase in comment.body:
- word = comment.body.replace(keyphrase, '')
- try:
- if isWord(word):
- # defintion
- words = dictionary.meaning(word)
- reply = [item[0] for item in words.values()]
- comment.reply(word + ': ' + reply[0])
- print('posted')
- else:
- reply = 'This is not a word.'
- comment.reply(reply)
- print('posted')
- except:
- print('to frequent')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement