delete yahooanswers -- the API was disabled

This commit is contained in:
Ryan Hitchman 2015-08-27 13:22:31 -07:00
parent 1543f7523d
commit e99867b2bc
1 changed files with 0 additions and 28 deletions

View File

@ -1,28 +0,0 @@
from util import hook, http
from random import choice
@hook.api_key('yahoo')
@hook.command
def answer(inp, api_key=None):
".answer <query> -- find the answer to a question on Yahoo! Answers"
url = "http://answers.yahooapis.com/AnswersService/V1/questionSearch"
result = http.get_json(url,
query=inp,
search_in="question",
output="json",
appid=api_key)
questions = result.get("all", {}).get("questions", [])
answered = filter(lambda x: x.get("ChosenAnswer", ""), questions)
if not answered:
return "no results"
chosen = choice(answered)
answer, link = chosen["ChosenAnswer"], chosen["Link"]
response = "%s -- %s" % (answer, link)
return " ".join(response.split())