Advertisement
Guest User

Lol_Reply_Bot

a guest
May 10th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. import praw
  2. import config
  3. import time
  4.  
  5. def authenticate():
  6.     print("Authenticating...")
  7.     reddit = praw.Reddit(username = config.username,
  8.                     password = config.password,
  9.                     client_id = config.client_id,
  10.                     client_secret = config.client_secret,
  11.                     user_agent="Lol_Reply_Bot made by /u/brodydrey2296 v1.0")
  12.     print("Authenticated as {}".format(reddit.user.me()))
  13.  
  14.     return reddit
  15.  
  16. def main():
  17.     reddit = authenticate()
  18.     while True:
  19.         run_bot(reddit)
  20.  
  21. def run_bot(reddit):
  22.     print("Obtaining 25 comments...")
  23.     for comment in reddit.subreddit('all').comments(limit=25):
  24.               if "lol" in comment.body:
  25.                   print ("String with 'lol' found in comment " + comment.id)
  26.                   comment.reply("The only reason people say lol is because it's kind of funny, but not funny enough to have any other sort of reaction than saying"
  27.                                 "lol'")
  28.                   print("Replied to comment") + comment.id
  29.  
  30.     print("Sleeping for 10 seconds...")
  31.     time.sleep(10)
  32.  
  33. if __name__ == '__main__':
  34.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement