Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import random
- import markovify
- reddit = praw.Reddit(client_id="XXX", client_secret="XXX",
- username="ChrisWeber", password="chriswebernospace", user_agent='markovbot)
- submission = reddit.subreddit('youtubehaiku').hot().next()
- submission.comments.replace_more(limit=None, threshold=1)
- comments = submission.comments.list()
- random_comment = random.choice(comments)
- author = random_comment.author
- compiled_text = ""
- for comment in author.comments.new(limit=None):
- compiled_text = compiled_text + comment.body.encode('utf-8').strip() + "\n"
- markov_chain = markovify.NewlineText(compiled_text)
- generated_sentence = markov_chain.make_sentence()
- print(generated_sentence)
- random_comment.reply(generated_sentence)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement