Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import praw
- import config
- import time
- """Globals"""
- BOT_TRIGGERS = ["Summoner=", "summoner=", "Summoner =", "summoner ="]
- BOT_RESPONSE = "[comment_split[1]](http://na.op.gg/summoner/userName="
- """Initializes OPGG Bot"""
- print("Logging into reddit")
- reddit = praw.Reddit(username = config.username,
- password = config.password,
- client_id = config.client_id,
- client_secret = config.client_secret,
- user_agent = config.user_agent)
- """Sets the subbreddit"""
- print("Retreiving subreddit: leagueoflegends")
- subreddit = reddit.subreddit("testingground4bots")
- print("Retrieving comments")
- comments = subreddit.stream.comments()
- """Initializes for loop to go through comments"""
- def OPGG_BOT():
- for comment in subreddit.comments(limit=100):
- try:
- cauthor = comment.author.name
- if BOT_TRIGGERS[0] or BOT_TRIGGERS[1] or BOT_TRIGGERS[2] or BOT_TRIGGERS[3] in comment.body:
- comment_spit = comment.body.split("=")
- SummonersName = comment_spit[1]
- tool_tip = '"' + SummonersName + '"'
- response = BOT_RESPONSE + SummonersName + " " + tool_tip +")"
- print("Replying to " + cauthor)
- comment.reply(response)
- except AttributeError:
- pass
- time.sleep(5)
- while True:
- OPGG_BOT()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement