diff --git a/.gitignore b/.gitignore
index 4932f03..4e2e627 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
*.cfg
*.pyc
+.idea/
bin/
include/
lib/
diff --git a/.idea/Shreddit.iml b/.idea/Shreddit.iml
new file mode 100644
index 0000000..a34a857
--- /dev/null
+++ b/.idea/Shreddit.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..e206d70
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..6e7abc9
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..a6ab262
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 0000000..922003b
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..c80f219
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/shreddit.py b/shreddit.py
index 1b94dbe..83c0fb8 100755
--- a/shreddit.py
+++ b/shreddit.py
@@ -1,20 +1,34 @@
-#!/usr/bin/env python3
+#!/usr/bin/env python
-import praw
-from praw.errors import *
+import os
import argparse
+
+from re import sub
+from random import shuffle, randint
from simpleconfigparser import simpleconfigparser
-from praw.objects import Comment, Submission
from datetime import datetime, timedelta
-from re import sub
-from time import sleep
+
+import praw
+from praw.errors import InvalidUser, InvalidUserPass, RateLimitExceeded
+from praw.objects import Comment, Submission
try:
- from loremipsum import get_sentence
+ from loremipsum import get_sentence # This only works on Python 2
except ImportError:
- def get_sentence():
- return '''I have been Shreddited for privacy!\n\n\
- https://github.com/x89/Shreddit/'''
+ if os.name == 'posix':
+ try:
+ # Try to generate a random string of words
+ fh = open('/usr/share/dict/words')
+ words = fh.read().splitlines()
+ fh.close()
+ shuffle(words)
+
+ def get_sentence():
+ return ' '.join(words[:randint(50, 150)])
+ except FileNotFoundError:
+ def get_sentence():
+ return '''I have been Shreddited for privacy!\n\n\
+ https://github.com/x89/Shreddit/'''
parser = argparse.ArgumentParser()
parser.add_argument(
@@ -52,12 +66,12 @@ def login(user=None, password=None):
r.login(_user, _pass)
else:
r.login() # Let the user supply details
+ except InvalidUser as e:
+ raise InvalidUser("User does not exist.", e)
except InvalidUserPass as e:
- raise InvalidUserPass(e)
- except RateLimitExceeded:
- raise RateLimitExceeded()
- except NonExistentUser:
- raise NonExistentUser("User does not exist")
+ raise InvalidUserPass("Specified an incorrect password.", e)
+ except RateLimitExceeded as e:
+ raise RateLimitExceeded("You're doing that too much.", e)
login(user=_user, password=_pass)
@@ -128,4 +142,4 @@ for thing in things:
print('Editing and deleting {msg}'.format(msg=msg))
thing.edit(replacement_text)
if not edit_only:
- thing.delete()
+ thing.delete()
\ No newline at end of file