def do_math(chan, dst, equation): try: res = eval(equation) except Exception, e: ircsock.reply(chan, dst, 'Error evaluating \002%s\002: %s' % (equation, e)) return
""" Copyright (C) 2011 Samuel Hoffman Interfaces math module to IRC """ import math from src import event, ircsock def do_math(chan, dst, equation): try: res = eval(equation) except Exception, e: ircsock.reply(chan, dst, 'Error evaluating \002%s\002: %s' % (equation, e)) return ircsock.reply(chan, dst, '%s' % res) event.command_add({ 'cmd': 'math', 'pkg': __name__, 'help': 'Interface Python\'s math module with IRC. Guide: http://docs.python.org/library/math.html', 'acl': 'admin', 'syntax': 'math.<method>([<arguments>])', 'code': do_math })