Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import config
- import time
- r = praw.Reddit(client_id=config.client_id, client_secret=config.client_secret, user_agent='NoThanksBot 1.0 by /u/NoThanksBot', username=config.username, password=config.password)
- words_to_match = ['want something?']
- cache = []
- def run_bot():
- subreddit = r.subreddit("test")
- print("Hacking subreddit")
- print("Scanning comments")
- posts = subreddit.new(limit = 5)
- comments = subreddit.comments(limit=20)
- for comment in comments:
- comment_text = comment.body.lower()
- isMatch = any(string in comment_text for string in words_to_match)
- if comment.id not in cache and isMatch:
- print("Match found! Comment ID: " +comment.id)
- comment.reply('No thanks.')
- print("User anihilated.")
- cache.append(comment.id)
- print("Anihilation finished. Restarting program.")
- count = 0
- while count < 50:
- run_bot()
- count += 1
- time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement