diff options
author | Sean B. Palmer <sbp@aldebaran.local> | 2010-11-06 13:58:51 +0000 |
---|---|---|
committer | Sean B. Palmer <sbp@aldebaran.local> | 2010-11-06 13:58:51 +0000 |
commit | ca95157acbe6e340573130e45a851b39e547159d (patch) | |
tree | 56f28aebc0c04aaf9a135c1194c44be959d2e8f0 | |
parent | 9ae58d0a353fc610e9affc1216b2cdc77e8cf89c (diff) | |
download | bot-ca95157acbe6e340573130e45a851b39e547159d.tar.gz bot-ca95157acbe6e340573130e45a851b39e547159d.tar.bz2 bot-ca95157acbe6e340573130e45a851b39e547159d.zip |
Calculator updates, and .py and .wa implementations.
-rwxr-xr-x | modules/calc.py | 21 | ||||
-rwxr-xr-x | modules/oblique.py | 4 |
2 files changed, 20 insertions, 5 deletions
diff --git a/modules/calc.py b/modules/calc.py index c4b304d..ab0f3fa 100755 --- a/modules/calc.py +++ b/modules/calc.py @@ -70,7 +70,7 @@ calc.example = '.calc 5 + 3' def c(phenny, input): """Google calculator.""" q = input.group(2).encode('utf-8') - q = q.replace('\xcf\x86', 'phi') # utf-8 U+03C6 + q = q.replace('\xcf\x95', 'phi') # utf-8 U+03D5 q = q.replace('\xcf\x80', 'pi') # utf-8 U+03C0 uri = 'http://www.google.com/ig/calculator?q=' bytes = web.get(uri + web.urllib.quote(q)) @@ -78,6 +78,7 @@ def c(phenny, input): answer = [p for p in parts if p.startswith('rhs: "')][0][6:] if answer: answer = answer.decode('unicode-escape') + answer = answer.replace(u'\xc2\xa0', ',') answer = answer.replace('<sup>', '^(') answer = answer.replace('</sup>', ')') answer = web.decode(answer) @@ -86,5 +87,23 @@ def c(phenny, input): c.commands = ['c'] c.example = '.c 5 + 3' +def py(phenny, input): + query = input.group(2) + uri = 'http://tumbolia.appspot.com/py/' + answer = web.get(uri + web.urllib.quote(query)) + if answer: + phenny.say(answer) + else: phenny.reply('Sorry, no result.') +py.commands = ['py'] + +def wa(phenny, input): + query = input.group(2) + uri = 'http://tumbolia.appspot.com/wa/' + answer = web.get(uri + web.urllib.quote(query)) + if answer: + phenny.say(answer) + else: phenny.reply('Sorry, no result.') +wa.commands = ['wa'] + if __name__ == '__main__': print __doc__.strip() diff --git a/modules/oblique.py b/modules/oblique.py index b19cb50..be1ca9d 100755 --- a/modules/oblique.py +++ b/modules/oblique.py @@ -87,10 +87,6 @@ o.commands = ['o'] o.example = '.o servicename arg1 arg2 arg3' o.services = {} -def py(phenny, input): - service(phenny, input, 'py', input.group(2)) -py.commands = ['py'] - def snippet(phenny, input): py = "BeautifulSoup.BeautifulSoup(re.sub('<.*?>|(?<= ) +', '', " + \ "eval(urllib.urlopen('http://ajax.googleapis.com/ajax/serv" + \ |