Guest User

Untitled

a guest
Dec 2nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. import praw
  2. bot = praw.Reddit(user_agent='Ice cream bot',
  3. client_id='',
  4. client_secret='',
  5. username='Icecream_above',
  6. password='')
  7. subreddit = bot.subreddit('PersonalBotTester')
  8. comments = subreddit.stream.comments()
  9. for comment in comments:
  10. text = comment.body # Fetch body
  11. author = comment.author # Fetch author
  12. text_file=open('c_save.txt', 'a')
  13. def text_open():
  14. text_file=open('c_save.txt', 'a')
  15. text_file.write(text + '\n')
  16. text_file.close()
  17. with open('c_save.txt') as f:
  18. data = f.readlines()
  19. if str(text + '\n') in data:
  20. pass
  21. if author == 'Icecream_above':
  22. pass
  23. else:
  24. if 'Ice cream' in text.lower():
  25. # Generate a message
  26. message = "How would you rate Ice cream on a scale 1-10?".format(author)
  27. text_open()
  28.  
  29. comment.reply(message) # Send message
  30. elif 'ice cream' in text.lower():
  31. message = "How would you rate ice cream on a scale 1-10?".format(author)
  32. text_open()
  33.  
  34. comment.reply(message)
Add Comment
Please, Sign In to add comment