Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- bot = praw.Reddit(user_agent='Ice cream bot',
- client_id='',
- client_secret='',
- username='Icecream_above',
- password='')
- subreddit = bot.subreddit('PersonalBotTester')
- comments = subreddit.stream.comments()
- for comment in comments:
- text = comment.body # Fetch body
- author = comment.author # Fetch author
- text_file=open('c_save.txt', 'a')
- def text_open():
- text_file=open('c_save.txt', 'a')
- text_file.write(text + '\n')
- text_file.close()
- with open('c_save.txt') as f:
- data = f.readlines()
- if str(text + '\n') in data:
- pass
- if author == 'Icecream_above':
- pass
- else:
- if 'Ice cream' in text.lower():
- # Generate a message
- message = "How would you rate Ice cream on a scale 1-10?".format(author)
- text_open()
- comment.reply(message) # Send message
- elif 'ice cream' in text.lower():
- message = "How would you rate ice cream on a scale 1-10?".format(author)
- text_open()
- comment.reply(message)
Add Comment
Please, Sign In to add comment