Advertisement
Guest User

Untitled

a guest
Jan 26th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import praw
  2. import config
  3. import time
  4.  
  5. """Globals"""
  6. BOT_TRIGGERS = ["Summoner=", "summoner=", "Summoner =", "summoner ="]
  7. BOT_RESPONSE = "[comment_split[1]](http://na.op.gg/summoner/userName="
  8.  
  9. """Initializes OPGG Bot"""
  10. print("Logging into reddit")
  11. reddit = praw.Reddit(username = config.username,
  12. password = config.password,
  13. client_id = config.client_id,
  14. client_secret = config.client_secret,
  15. user_agent = config.user_agent)
  16.  
  17. """Sets the subbreddit"""
  18. print("Retreiving subreddit: leagueoflegends")
  19. subreddit = reddit.subreddit("testingground4bots")
  20. print("Retrieving comments")
  21. comments = subreddit.stream.comments()
  22.  
  23. """Initializes for loop to go through comments"""
  24. def OPGG_BOT():
  25. for comment in subreddit.comments(limit=100):
  26. try:
  27. cauthor = comment.author.name
  28.  
  29. if BOT_TRIGGERS[0] or BOT_TRIGGERS[1] or BOT_TRIGGERS[2] or BOT_TRIGGERS[3] in comment.body:
  30. comment_spit = comment.body.split("=")
  31. SummonersName = comment_spit[1]
  32. tool_tip = '"' + SummonersName + '"'
  33. response = BOT_RESPONSE + SummonersName + " " + tool_tip +")"
  34. print("Replying to " + cauthor)
  35. comment.reply(response)
  36. except AttributeError:
  37. pass
  38. time.sleep(5)
  39.  
  40. while True:
  41. OPGG_BOT()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement