Added error checking for empty parameters
parent
6c00d59973
commit
482161e98b
|
@ -69,6 +69,8 @@ calc.example = '.calc 5 + 3'
|
||||||
|
|
||||||
def c(phenny, input):
|
def c(phenny, input):
|
||||||
"""Google calculator."""
|
"""Google calculator."""
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("Nothing to calculate.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
q = q.replace('\xcf\x95', 'phi') # utf-8 U+03D5
|
q = q.replace('\xcf\x95', 'phi') # utf-8 U+03D5
|
||||||
q = q.replace('\xcf\x80', 'pi') # utf-8 U+03C0
|
q = q.replace('\xcf\x80', 'pi') # utf-8 U+03C0
|
||||||
|
@ -99,6 +101,8 @@ def py(phenny, input):
|
||||||
py.commands = ['py']
|
py.commands = ['py']
|
||||||
|
|
||||||
def wa(phenny, input):
|
def wa(phenny, input):
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("No search term.")
|
||||||
query = input.group(2).encode('utf-8')
|
query = input.group(2).encode('utf-8')
|
||||||
uri = 'http://tumbolia.appspot.com/wa/'
|
uri = 'http://tumbolia.appspot.com/wa/'
|
||||||
answer = web.get(uri + web.urllib.quote(query))
|
answer = web.get(uri + web.urllib.quote(query))
|
||||||
|
|
|
@ -22,6 +22,8 @@ r_info = re.compile(
|
||||||
)
|
)
|
||||||
|
|
||||||
def dict(phenny, input):
|
def dict(phenny, input):
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("Nothing to define.")
|
||||||
word = input.group(2)
|
word = input.group(2)
|
||||||
word = urllib.quote(word.encode('utf-8'))
|
word = urllib.quote(word.encode('utf-8'))
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,8 @@ r_query = re.compile(
|
||||||
)
|
)
|
||||||
|
|
||||||
def gcs(phenny, input):
|
def gcs(phenny, input):
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("Nothing to compare.")
|
||||||
queries = r_query.findall(input.group(2))
|
queries = r_query.findall(input.group(2))
|
||||||
if len(queries) > 6:
|
if len(queries) > 6:
|
||||||
return phenny.reply('Sorry, can only compare up to six things.')
|
return phenny.reply('Sorry, can only compare up to six things.')
|
||||||
|
|
|
@ -11,6 +11,8 @@ import web
|
||||||
|
|
||||||
def val(phenny, input):
|
def val(phenny, input):
|
||||||
"""Check a webpage using the W3C Markup Validator."""
|
"""Check a webpage using the W3C Markup Validator."""
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("Nothing to validate.")
|
||||||
uri = input.group(2)
|
uri = input.group(2)
|
||||||
if not uri.startswith('http://'):
|
if not uri.startswith('http://'):
|
||||||
uri = 'http://' + uri
|
uri = 'http://' + uri
|
||||||
|
|
|
@ -72,6 +72,8 @@ def format(word, definitions, number=2):
|
||||||
return result.strip(' .,')
|
return result.strip(' .,')
|
||||||
|
|
||||||
def w(phenny, input):
|
def w(phenny, input):
|
||||||
|
if not input.group(2):
|
||||||
|
return phenny.reply("Nothing to define.")
|
||||||
word = input.group(2)
|
word = input.group(2)
|
||||||
etymology, definitions = wiktionary(word)
|
etymology, definitions = wiktionary(word)
|
||||||
if not definitions:
|
if not definitions:
|
||||||
|
|
Loading…
Reference in New Issue