Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/python3
- """
- Based upon the RedditBot of shantnu:
- https://github.com/shantnu/RedditBot/
- """
- """
- The MIT License (MIT)
- Copyright (c) 2016 welovewhales
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
- """
- import praw
- import time
- ##############VARIABLES##################
- user_agent = "DistroWatchBot 0.1"
- subreddit = "linuxquestions"
- keywords = ['choose', 'choosing', 'help', 'picking', 'pick']
- key_tmp = []
- REDDIT_USERNAME = "USER_NAME_HERE"
- REDDIT_PASS = "PSWD_IN_PLAIN_TEXT"
- replied = []
- ##################CAPATILIZE KEYWORDS###################
- for i in keywords:
- key_tmp.append(i.title())
- key_tmp.append(i)
- keywords = key_tmp
- #############CONNECT TO REDDIT#############
- reddit = praw.Reddit(user_agent = user_agent)
- sreddit = reddit.get_subreddit(subreddit)
- reddit.login(REDDIT_USERNAME, REDDIT_PASS, disable_warning=True)
- ############FUN BEGINS##########################
- while True:
- print("Going for it")
- for submission in sreddit.get_new(limit = 10):
- if submission.id not in replied:
- for i in keywords:
- if i in submission.title:
- if 'Distro' in submission.title:
- replied.append(submission.id)
- submission.add_comment("You triggered this bot! Please visit http://www.distrowatch.com for your answer, thanks!")
- print("succes!",submission.title)
- elif 'distro' in submission.title:
- replied.append(submission.id)
- submission.add_comment("You triggered this bot! Please visit http://www.distrowatch.com for your answer, thanks!")
- print("succes!", submission.title)
- print("sleeping for 5 minutes")
- time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement