summaryrefslogtreecommitdiffstats
path: root/modules/calc.py
diff options
context:
space:
mode:
authorSteve Vaught <Steven.D.Vaught@gmail.com>2011-04-19 00:50:58 -0400
committerSteve Vaught <Steven.D.Vaught@gmail.com>2011-04-19 00:50:58 -0400
commit482161e98b254c4d67a81def8c726dad7bf03af8 (patch)
tree41cf0f9f96637b126f3e6c177ed1a8d02f2f46a5 /modules/calc.py
parent6c00d59973d59cc7ac97fde35739038eece2513b (diff)
downloadbot-482161e98b254c4d67a81def8c726dad7bf03af8.tar.gz
bot-482161e98b254c4d67a81def8c726dad7bf03af8.tar.bz2
bot-482161e98b254c4d67a81def8c726dad7bf03af8.zip
Added error checking for empty parameters
Diffstat (limited to 'modules/calc.py')
-rwxr-xr-xmodules/calc.py4
1 files changed, 4 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))