Advertisement
Guest User

Untitled

a guest
May 21st, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.57 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. """
  4. Based upon the RedditBot of shantnu:
  5. https://github.com/shantnu/RedditBot/
  6. """
  7.  
  8. """
  9. The MIT License (MIT)
  10.  
  11. Copyright (c) 2016 welovewhales
  12.  
  13. Permission is hereby granted, free of charge, to any person obtaining a copy
  14. of this software and associated documentation files (the "Software"), to deal
  15. in the Software without restriction, including without limitation the rights
  16. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17. copies of the Software, and to permit persons to whom the Software is
  18. furnished to do so, subject to the following conditions:
  19.  
  20. The above copyright notice and this permission notice shall be included in all
  21. copies or substantial portions of the Software.
  22.  
  23. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  28. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  29. SOFTWARE.
  30. """
  31.  
  32. import praw
  33. import time
  34.  
  35. ##############VARIABLES##################
  36. user_agent = "DistroWatchBot 0.1"
  37. subreddit = "linuxquestions"
  38. keywords = ['choose', 'choosing', 'help', 'picking', 'pick']
  39. key_tmp = []
  40. REDDIT_USERNAME = "USER_NAME_HERE"
  41. REDDIT_PASS = "PSWD_IN_PLAIN_TEXT"
  42. replied = []
  43.  
  44. ##################CAPATILIZE KEYWORDS###################
  45. for i in keywords:
  46.     key_tmp.append(i.title())
  47.     key_tmp.append(i)
  48. keywords = key_tmp
  49.  
  50. #############CONNECT TO REDDIT#############
  51. reddit = praw.Reddit(user_agent = user_agent)
  52. sreddit = reddit.get_subreddit(subreddit)
  53. reddit.login(REDDIT_USERNAME, REDDIT_PASS, disable_warning=True)
  54.  
  55.  
  56.  
  57. ############FUN BEGINS##########################
  58. while True:
  59.     print("Going for it")
  60.     for submission in sreddit.get_new(limit = 10):
  61.         if submission.id not in replied:
  62.             for i in keywords:
  63.                 if i in submission.title:
  64.                     if 'Distro' in submission.title:
  65.                         replied.append(submission.id)
  66.                         submission.add_comment("You triggered this bot! Please visit http://www.distrowatch.com for your answer, thanks!")
  67.                         print("succes!",submission.title)
  68.                     elif 'distro' in submission.title:
  69.                         replied.append(submission.id)
  70.                         submission.add_comment("You triggered this bot! Please visit http://www.distrowatch.com for your answer, thanks!")
  71.                         print("succes!", submission.title)
  72.     print("sleeping for 5 minutes")
  73.     time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement