Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import pdb
- import re
- import os
- reddit=praw.Reddit(client_id='',
- client_secret='',
- username='',
- password='',
- user_agent='circlebot')
- if not os.path.isfile("posts_replie_to.txt"):
- posts_replie_to = []
- else:
- with open("posts_replie_to.txt", "r") as f:
- posts_replie_to = f.read()
- posts_replie_to = posts_replie_to.split("\n")
- posts_replie_to = list(filter(None, posts_replie_to))
- subreddit = reddit.subreddit('snakeroomalliance')
- comments = subreddit.stream.comments()
- for comment in comments:
- if comment.id not in posts_replie_to:
- print 'hello'
- if re.search("sneks", comment.body, re.IGNORECASE):
- message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
- comment.reply(message)
- print("Bot replying to : ", comment.body)
- posts_replie_to.append(comment.id)
- with open("posts_replie_to.txt", "w") as f:
- for comment_id in posts_replie_to:
- f.write(comment_id + "\n")
- if re.search("snake", comment.body, re.IGNORECASE):
- message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
- comment.reply(message)
- print("Bot replying to : ", comment.body)
- posts_replie_to.append(comment.id)
- with open("posts_replie_to.txt", "w") as f:
- for comment_id in posts_replie_to:
- f.write(comment_id + "\n")
- if re.search("snek", comment.body, re.IGNORECASE):
- message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
- comment.reply(message)
- print("Bot replying to : ", comment.body)
- posts_replie_to.append(comment.id)
- with open("posts_replie_to.txt", "w") as f:
- for comment_id in posts_replie_to:
- f.write(comment_id + "\n")
- if re.search("snakes", comment.body, re.IGNORECASE):
- message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
- comment.reply(message)
- print("Bot replying to : ", comment.body)
- posts_replie_to.append(comment.id)
- with open("posts_replie_to.txt", "w") as f:
- for comment_id in posts_replie_to:
- f.write(comment_id + "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement