show urls in !wikipedia output

This commit is contained in:
jesopo 2019-11-26 14:18:18 +00:00
parent 63d9ab19d5
commit 76ccbbbc46

View file

@ -14,17 +14,20 @@ class Module(ModuleManager.BaseModule):
:usage: <term>
"""
page = utils.http.request(URL_WIKIPEDIA, get_params={
"action": "query", "prop": "extracts",
"titles": event["args"], "exintro": "",
"explaintext": "", "exchars": "500",
"redirects": "", "format": "json"}).json()
"action": "query", "prop": "extracts|info", "inprop": "url",
"titles": event["args"], "exintro": "", "explaintext": "",
"exchars": "500", "redirects": "", "format": "json"}).json()
if page:
pages = page["query"]["pages"]
article = list(pages.items())[0][1]
if not "missing" in article:
title, info = article["title"], article["extract"]
info = info.replace("\n\n", " ").split("\n")[0]
event["stdout"].write("%s: %s" % (title, info))
title = article["title"]
info = utils.parse.line_normalise(article["extract"])
url = article["fullurl"]
event["stdout"].write("%s: %s - %s" % (title, info, url))
else:
event["stderr"].write("No results found")
else: