@@ -0,0 +1,1683 @@
+import requests%0Aimport urllib%0Aimport logging%0A%0Atry:%0A  from lxml import etree%0A  print(%22running with lxml.etree%22)%0Aexcept ImportError:%0A  print(%22module_wolfram_alpha requires lxml.etree for xpath support%22)%0A%0Aappid = None%0Aquery = %22http://api.wolframalpha.com/v2/query?input=%25s&appid=%25s%22%0A%0Alog = logging.getLogger('wolfram_alpha')%0A%0Adef init(bot):%0A    global appid%0A    config = bot.config.get(%22module_wolfram_alpha%22, %7B%7D)%0A    appid = config.get(%22appid%22, %22%22)%0A    if appid:%0A        log.info(%22Using Wolfram Alpha appid %25s%22 %25 appid)%0A    else:%0A        log.warning(%22Appid not found from config!%22)%0A%0Adef command_wa(bot, user, channel, args):%0A    %22%22%22Query Wolfram Alpha%22%22%22%0A    if not appid:%0A        log.warn(%22Appid not specified in configuration!%22)%0A        return%0A%0A    r = requests.get(query %25 (urllib.quote(args), appid))%0A%0A    if r.status_code != 200: return%0A%0A    root = etree.fromstring(r.content)%0A    # find all pods%0A    pods = root.findall(%22pod%22)%0A%0A    # no answer pods found, check if there are didyoumeans-elements%0A    if not pods: %0A        didyoumeans = root.find(%22didyoumeans%22)%0A        # no support for future stuff yet, TODO?%0A        if not didyoumeans: return%0A%0A        options = %5B%5D%0A        for didyoumean in didyoumeans:%0A            options.append(%22'%25s'%22 %25 didyoumean.text)%0A        line = %22 or %22.join(options)%0A        line = %22Did you mean %25s?%22 %25 line%0A        return bot.say(channel, line.encode(%22UTF-8%22))%0A%0A    # first pod has the question as WA sees it%0A    question = pods%5B0%5D.xpath(%22subpod/plaintext%22)%5B0%5D.text%0A    # second one has the best answer%0A    answer = pods%5B1%5D.xpath(%22subpod/plaintext%22)%5B0%5D.text%0A%0A    line = %22%25s: %25s%22 %25 (question, answer)%0A    return bot.say(channel, line.encode(%22UTF-8%22))%0A

Add module for wolfram alpha queries via their API