diff options
| author | 2019-11-26 14:18:18 +0000 | |
|---|---|---|
| committer | 2019-11-26 14:18:18 +0000 | |
| commit | 76ccbbbc46812da58e0e314b0f558b39bf91abb4 (patch) | |
| tree | bbddf23788788b2ca05f41ae009ba0c4471b1af3 | |
| parent | add more.py (diff) | |
| signature | ||
show urls in !wikipedia output
| -rw-r--r-- | modules/wikipedia.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/modules/wikipedia.py b/modules/wikipedia.py index 41ed7fdc..3eae02b6 100644 --- a/modules/wikipedia.py +++ b/modules/wikipedia.py @@ -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: |
