Advertisement
Guest User

Untitled

a guest
Apr 6th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. import praw
  2. import pdb
  3. import re
  4. import os
  5.  
  6. reddit=praw.Reddit(client_id='',
  7. client_secret='',
  8. username='',
  9. password='',
  10. user_agent='circlebot')
  11.  
  12.  
  13.  
  14. if not os.path.isfile("posts_replie_to.txt"):
  15. posts_replie_to = []
  16. else:
  17. with open("posts_replie_to.txt", "r") as f:
  18. posts_replie_to = f.read()
  19. posts_replie_to = posts_replie_to.split("\n")
  20. posts_replie_to = list(filter(None, posts_replie_to))
  21.  
  22. subreddit = reddit.subreddit('snakeroomalliance')
  23. comments = subreddit.stream.comments()
  24. for comment in comments:
  25. if comment.id not in posts_replie_to:
  26. print 'hello'
  27. if re.search("sneks", comment.body, re.IGNORECASE):
  28. message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
  29. comment.reply(message)
  30. print("Bot replying to : ", comment.body)
  31. posts_replie_to.append(comment.id)
  32. with open("posts_replie_to.txt", "w") as f:
  33. for comment_id in posts_replie_to:
  34. f.write(comment_id + "\n")
  35.  
  36.  
  37.  
  38. if re.search("snake", comment.body, re.IGNORECASE):
  39. message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
  40. comment.reply(message)
  41. print("Bot replying to : ", comment.body)
  42. posts_replie_to.append(comment.id)
  43. with open("posts_replie_to.txt", "w") as f:
  44. for comment_id in posts_replie_to:
  45. f.write(comment_id + "\n")
  46.  
  47.  
  48. if re.search("snek", comment.body, re.IGNORECASE):
  49. message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
  50. comment.reply(message)
  51. print("Bot replying to : ", comment.body)
  52. posts_replie_to.append(comment.id)
  53. with open("posts_replie_to.txt", "w") as f:
  54. for comment_id in posts_replie_to:
  55. f.write(comment_id + "\n")
  56.  
  57.  
  58. if re.search("snakes", comment.body, re.IGNORECASE):
  59. message=("#/u/%s snakes are bad very bad greetings /r/circularswarm") % comment.author
  60. comment.reply(message)
  61. print("Bot replying to : ", comment.body)
  62. posts_replie_to.append(comment.id)
  63. with open("posts_replie_to.txt", "w") as f:
  64. for comment_id in posts_replie_to:
  65. f.write(comment_id + "\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement