Moved calculation to the wolframalpha plugin (the old google calculator plugin no longer works correctly, sorry!(=)

This commit is contained in:
Luke Rogers 2013-11-11 10:01:45 +13:00
parent b6d1620cec
commit cd4b65de3d
2 changed files with 2 additions and 20 deletions

View File

@ -1,20 +0,0 @@
from util import hook, http
@hook.command("math")
@hook.command
def calc(inp):
"""calc <term> -- Calculate <term> with Google Calc."""
soup = http.get_soup('http://www.google.com/search', q=inp, cookies=True, user_agent=http.ua_internetexplorer)
result = soup.find('h2', {'class': 'r'})
exponent = result.find('sup')
if not result:
return "Could not calculate '{}'".format(inp)
if not exponent:
return result.contents[0]
if exponent:
return "{}^{}".format(result.contents[0]*2)

View File

@ -3,6 +3,8 @@ import re
from util import hook, http, text, web
@hook.command('math')
@hook.command('calc')
@hook.command('wa')
@hook.command
def wolframalpha(inp, bot=None):