aboutsummaryrefslogtreecommitdiff
path: root/ponysay.py
diff options
context:
space:
mode:
Diffstat (limited to 'ponysay.py')
-rwxr-xr-xponysay.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/ponysay.py b/ponysay.py
index 1f52558..969ecb6 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -367,15 +367,19 @@ class ponysay():
alts.append(pair)
pairs = alts
- pair = pairs[random.randrange(0, len(pairs))]
- qfile = None
- try:
- qfile = open(pair[1], 'r')
- args.message = '\n'.join(qfile.readlines())
- finally:
- if qfile is not None:
- qfile.close()
- args.pony = [pair[0]]
+ if not len(pairs) == 0:
+ pair = pairs[random.randrange(0, len(pairs))]
+ qfile = None
+ try:
+ qfile = open(pair[1], 'r')
+ args.message = '\n'.join(qfile.readlines()).strip()
+ finally:
+ if qfile is not None:
+ qfile.close()
+ args.pony = [pair[0]]
+ else:
+ args.pony = args.quote
+ args.message = 'I got nuthin\' good to say :('
self.print_pony(args)