summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean B. Palmer <sean@miscoranda.com>2011-06-17 08:48:39 -0700
committerSean B. Palmer <sean@miscoranda.com>2011-06-17 08:48:39 -0700
commitbbd2c7f94320a1e831c58acaac3a361b71caefea (patch)
treefd3e15ba6d31f2e9397c972d0028c3c562afcd3b
parent78ec2730460e8271e3a9d96056799785e6866f83 (diff)
parent482161e98b254c4d67a81def8c726dad7bf03af8 (diff)
downloadbot-bbd2c7f94320a1e831c58acaac3a361b71caefea.tar.gz
bot-bbd2c7f94320a1e831c58acaac3a361b71caefea.tar.bz2
bot-bbd2c7f94320a1e831c58acaac3a361b71caefea.zip
Merge pull request #6 from Steve-V/master
Some commands use input without checking if it's actually been provided
-rwxr-xr-xmodules/calc.py4
-rwxr-xr-xmodules/dict.py2
-rwxr-xr-xmodules/search.py2
-rwxr-xr-xmodules/validate.py2
-rwxr-xr-xmodules/wiktionary.py2
5 files changed, 12 insertions, 0 deletions
diff --git a/modules/calc.py b/modules/calc.py
index 88ac814..5a72e10 100755
--- a/modules/calc.py
+++ b/modules/calc.py
@@ -69,6 +69,8 @@ calc.example = '.calc 5 + 3'
def c(phenny, input):
"""Google calculator."""
+ if not input.group(2):
+ return phenny.reply("Nothing to calculate.")
q = input.group(2).encode('utf-8')
q = q.replace('\xcf\x95', 'phi') # utf-8 U+03D5
q = q.replace('\xcf\x80', 'pi') # utf-8 U+03C0
@@ -99,6 +101,8 @@ def py(phenny, input):
py.commands = ['py']
def wa(phenny, input):
+ if not input.group(2):
+ return phenny.reply("No search term.")
query = input.group(2).encode('utf-8')
uri = 'http://tumbolia.appspot.com/wa/'
answer = web.get(uri + web.urllib.quote(query))
diff --git a/modules/dict.py b/modules/dict.py
index 125f686..8f13e99 100755
--- a/modules/dict.py
+++ b/modules/dict.py
@@ -22,6 +22,8 @@ r_info = re.compile(
)
def dict(phenny, input):
+ if not input.group(2):
+ return phenny.reply("Nothing to define.")
word = input.group(2)
word = urllib.quote(word.encode('utf-8'))
diff --git a/modules/search.py b/modules/search.py
index 1067531..d83a47e 100755
--- a/modules/search.py
+++ b/modules/search.py
@@ -69,6 +69,8 @@ r_query = re.compile(
)
def gcs(phenny, input):
+ if not input.group(2):
+ return phenny.reply("Nothing to compare.")
queries = r_query.findall(input.group(2))
if len(queries) > 6:
return phenny.reply('Sorry, can only compare up to six things.')
diff --git a/modules/validate.py b/modules/validate.py
index 185623f..85815d1 100755
--- a/modules/validate.py
+++ b/modules/validate.py
@@ -11,6 +11,8 @@ import web
def val(phenny, input):
"""Check a webpage using the W3C Markup Validator."""
+ if not input.group(2):
+ return phenny.reply("Nothing to validate.")
uri = input.group(2)
if not uri.startswith('http://'):
uri = 'http://' + uri
diff --git a/modules/wiktionary.py b/modules/wiktionary.py
index c8f665e..4a5f407 100755
--- a/modules/wiktionary.py
+++ b/modules/wiktionary.py
@@ -72,6 +72,8 @@ def format(word, definitions, number=2):
return result.strip(' .,')
def w(phenny, input):
+ if not input.group(2):
+ return phenny.reply("Nothing to define.")
word = input.group(2)
etymology, definitions = wiktionary(word)
if not definitions: