Added basic Yahoo answers plugin.
This commit is contained in:
parent
d49d7e6272
commit
1ea59ad7ad
1 changed files with 14 additions and 0 deletions
14
plugins/answers.py
Normal file
14
plugins/answers.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from util import hook, web, text
|
||||||
|
|
||||||
|
|
||||||
|
@hook.command
|
||||||
|
def answer(inp):
|
||||||
|
".answer <query> -- find the answer to a question on Yahoo! Answers"
|
||||||
|
|
||||||
|
query = "SELECT Subject, ChosenAnswer, Link FROM answers.search WHERE query=@query LIMIT 1"
|
||||||
|
result = web.query(query, {"query": inp.strip()}).one()
|
||||||
|
|
||||||
|
short_url = web.isgd(result["Link"])
|
||||||
|
answer = text.truncate_str(result["ChosenAnswer"], 80)
|
||||||
|
|
||||||
|
return u"{} {} - {}".format(result["Subject"], answer, short_url)
|
Reference in a new issue