Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import praw
  2. import time
  3.  
  4.  
  5. path = 'commented.txt'
  6.  
  7. header = '\n\n *2bot2t Version 0.1, PM /u/HouseCasterly with suggestions/issues. 6783.*'
  8.  
  9. links = '\n\n [Join us](http://discord.gg/pzGpnhQ)'
  10.  
  11. def authenticate():
  12.    
  13.     print('Authenticating...\n')
  14.     reddit = praw.Reddit('2bot2t', user_agent = 'A 2b2t Bot')
  15.     print('Authenticated as {}\n'.format(reddit.user.me()))
  16.     return reddit
  17.  
  18. def run_2bot2t(reddit):
  19.     with open(path, 'r') as f:
  20.         prev_comments = f.read().splitlines()
  21.  
  22.     print("Getting 250 comments...\n")
  23.  
  24.     for comment in reddit.subreddit('2b2t').comments(limit=250):
  25.         match = re.findall("kek",comment.body)
  26.  
  27.         if match:
  28.             print("Name found in comment with comment ID: " + comment.id)
  29.  
  30.             if comment.id not in prev_comments and comment.author.name != "2bot2t":
  31.                 print('Commenter is a filthy infidel... fixing their ways...\n')
  32.                 prev_comments.append(comment.id)
  33.                 with open(path, 'a+') as f:
  34.                   f.write(comment.id + '\n')
  35.  
  36.                 comment.reply("Halt in the name of Zozzle, filthy infidel! I'm going to hope you meant to say Zoz(zle) instead of K*k." + header)
  37.                 time.sleep(600)
  38.  
  39.             else:
  40.                 print('The keker has been assimilated.')
  41.  
  42.         else:
  43.             print('Comment Searched, no incorrect kekage\n')
  44.  
  45. def main():
  46.     reddit = authenticate()
  47.     while True:
  48.         run_2bot2t(reddit)
  49.  
  50.  
  51. if __name__ == '__main__':
  52.     main()
  53.  
  54.  
  55. dmis8as
  56. dmitguc
  57. dmitmcw
  58. dmitz1i
  59.  
  60.  
  61. [2bot2t]
  62. username: 2bot2t
  63. password:
  64. client_id: Mq-McO-3HIaD1Q
  65. client_secret: D35NTkwpsi2aoqtyaGI5LDquNs8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement