Merge pull request #125 from TheFiZi/patch-3

Added handling of exponents
This commit is contained in:
Luke Rogers 2013-09-02 16:18:59 -07:00
commit b499c3848e

View file

@ -1,6 +1,5 @@
from util import hook, http
@hook.command("math")
@hook.command
def calc(inp):
@ -9,7 +8,11 @@ def calc(inp):
soup = http.get_soup('http://www.google.com/search', q=inp)
result = soup.find('h2', {'class': 'r'})
exponent = result.find('sup')
if not result:
return "Could not calculate '%s'" % inp
return result.contents[0]
if not exponent:
return result.contents[0]
if exponent:
return result.contents[0] + "^" + exponent.contents[0]