def watime(inp, bot=None):
"""time <area> -- Gets the time in <area>"""
query = "current time in {}".format(inp)
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
if not api_key:
return "error: no wolfram alpha api key set"
request = http.get_xml(api_url, input=query, appid=api_key)
time = " ".join(request.xpath("//pod[@title='Result']/subpod/plaintext/text()"))
time = time.replace(" | ", ", ")
if time:
# nice place name for UNIX time
if inp.lower() == "unix":
place = "Unix Epoch"
else:
place = capitalize_first(" ".join(request.xpath("//pod[@"
"title='Input interpretation']/subpod/plaintext/text()"))[
16:])
return "{} - \x02{}\x02".format(time, place)
else:
return u"Could not get the time for '{}'.".format(inp)
评论列表
文章目录