Last active
September 21, 2017 17:15
-
-
Save PythonCoderAS/f2956909fac845453767d3313fae8323 to your computer and use it in GitHub Desktop.
Easy way to delete posts by your bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import praw | |
| u = '' | |
| p = '' | |
| c_id = '' | |
| c_secret = '' | |
| reddit = praw.Reddit(username = u, password = p, client_id = c_id, cient_secret = c_secret) | |
| def main(): | |
| try: | |
| for item in reddit.inbox.stream(): | |
| try: | |
| if 'delete' in item.body.lower(): | |
| item.parent().delete() | |
| except: | |
| pass | |
| while True: | |
| try: | |
| main() | |
| except(KeyboardInterrupt): | |
| raise KeyboardInterrupt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recursive call in the except-block gives me the chills. You should get rid of the inner try/except block, and just do all the exception handling on the outside.