├── README.md ├── .gitignore ├── LICENSE └── ndt.py /README.md: -------------------------------------------------------------------------------- 1 | NobodyDoesThis 2 | ============== 3 | 4 | Reddit bot that scans 3 day-old /r/DoesAnybodyElse posts 0 score and then comments "Nope, it's just you." 5 | 6 | settings.cfg 7 | ============ 8 | 9 | Create a file called `settings.cfg` in the following format: 10 | 11 | [auth] 12 | username=xxxxxxxxxxxxxxxxxx 13 | password=xxxxxxxxxxxxxxxxxx -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | __pycache__ 21 | 22 | # Installer logs 23 | pip-log.txt 24 | 25 | # Unit test / coverage reports 26 | .coverage 27 | .tox 28 | nosetests.xml 29 | 30 | # Translations 31 | *.mo 32 | 33 | # Mr Developer 34 | .mr.developer.cfg 35 | .project 36 | .pydevproject 37 | 38 | # Komodo 39 | .komodotools/ 40 | *.komodoproject 41 | 42 | settings.cfg -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2013 Karan Goel 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, 8 | merge, publish, distribute, sublicense, and/or sell copies of the 9 | Software, and to permit persons to whom the Software is furnished 10 | to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. -------------------------------------------------------------------------------- /ndt.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import ConfigParser 4 | from datetime import datetime 5 | import time 6 | import sys 7 | 8 | import praw 9 | 10 | 11 | USER_AGENT = '/u/NobodyDoesThis by /u/karangoeluw' 12 | 13 | MESSAGE = ''' 14 | Nope, it's just you. 15 | 16 | ------ 17 | [^NobodyDoesThis](https://github.com/karan/NobodyDoesThis) \ 18 | ^bot ^by [^Karan ^Goel](http://www.goel.im/) 19 | --- 20 | ''' 21 | 22 | SLEEP_AFTER_COMMENTING = 2 # seconds to sleep after commenting 23 | IGNORE_FIRST_SUBMISSIONS = 100 24 | 25 | r = praw.Reddit(user_agent=USER_AGENT) 26 | 27 | config = ConfigParser.ConfigParser() 28 | config.read('settings.cfg') 29 | username = config.get('auth', 'username') 30 | password = config.get('auth', 'password') 31 | print '[*] Logging in as %s...' % username 32 | r.login(username, password) 33 | print '[*] Login successful...\n' 34 | 35 | dae = r.get_subreddit('DoesAnybodyElse') # praw.objects.Subreddit 36 | 37 | print '[*] Getting submissions...\n' 38 | 39 | already_done = set() 40 | 41 | posted = 0 # number of comments posted this session 42 | 43 | for count, submission in enumerate(dae.get_hot(limit=None)): 44 | # skip the first few submissions 45 | if count > IGNORE_FIRST_SUBMISSIONS and submission.id not in already_done: 46 | already_done.add(submission.id) 47 | 48 | sys.stdout.write('\r[*] %d threads processed [*] %d comments posted' % 49 | ((count - IGNORE_FIRST_SUBMISSIONS), posted)) 50 | sys.stdout.flush() 51 | 52 | # make sure i haven't posted here earlier 53 | already_posted = False 54 | for comment in submission.comments: 55 | if comment.author == username: 56 | already_posted = True 57 | 58 | created = datetime.fromtimestamp(submission.created_utc) # epoch to datetime 59 | diff = (datetime.now() - created).total_seconds() / 60 / 60 / 24 # num days 60 | if (not already_posted and diff >= 3 and submission.score == 0): # post is older 3 days 61 | # score = 0 62 | comment = submission.add_comment(MESSAGE) 63 | #print '\n[*] %s' % submission.title 64 | #print '\tComment: %s' % comment.permalink 65 | time.sleep(SLEEP_AFTER_COMMENTING) # sleep for seconds after commenting 66 | #time.sleep(2) # to comply with rate limit 67 | --------------------------------------------------------------------------------