def slogan(text): """slogan <word> -- Makes a slogan for <word>.""" out = random.choice(slogans) if text.lower() and out.startswith("<text>"): text = formatting.capitalize_first(text) return out.replace('<text>', text)
def time_command(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) current_time = " ".join( request.xpath("//pod[@title='Result']/subpod/plaintext/text()")) current_time = current_time.replace(" | ", ", ") if current_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(current_time, place) else: return "Could not get the time for '{}'.".format(inp)
def time_command(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) current_time = " ".join(request.xpath("//pod[@title='Result']/subpod/plaintext/text()")) current_time = current_time.replace(" | ", ", ") if current_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(current_time, place) else: return "Could not get the time for '{}'.".format(inp)