Remove debug print, improve wikipedia.py

This commit is contained in:
jesopo 2018-08-04 12:48:38 +01:00
parent 21c1db2965
commit fbd6975351
2 changed files with 7 additions and 6 deletions

View file

@ -115,7 +115,6 @@ class Server(object):
def has_user(self, nickname):
return nickname.lower() in self.users
def get_user(self, nickname):
print(self.users)
if not self.has_user(nickname):
new_user = IRCUser.User(nickname, self, self.bot)
self.bot.events.on("new").on("user").call(

View file

@ -11,13 +11,15 @@ class Module(object):
def wikipedia(self, event):
page = Utils.get_url(URL_WIKIPEDIA, get_params={
"action": "query", "prop": "extracts",
"titles": event["args"], "exsentences": "2",
"explaintext": "", "formatversion": "2",
"format": "json"}, json=True)
"titles": event["args"], "exintro": "",
"explaintext": "", "exchars": "500",
"redirects": "", "format": "json"}, json=True)
if page:
if not "missing" in page["query"]["pages"][0]:
article = page["query"]["pages"][0]
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))
else:
event["stderr"].write("No results found")