From 906ff4361a154fa3fcfe5d01e4af93eb142f5bcb Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Fri, 3 Apr 2020 16:38:54 +0200 Subject: [PATCH] Fixed some things with wiki command --- funcs/gwendolynFuncs.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/funcs/gwendolynFuncs.py b/funcs/gwendolynFuncs.py index cdde27f..6e70313 100644 --- a/funcs/gwendolynFuncs.py +++ b/funcs/gwendolynFuncs.py @@ -126,15 +126,21 @@ def findWikiPage(search : str): wikia.set_lang("da") searchResults = wikia.search("senkulpa",search) if len(searchResults) > 0: - logThis("Found it") - page = wikia.page("senkulpa",searchResults[0]) - content = page.content.replace(u'\xa0', u' ').split("\n")[0] + try: + searchResult = searchResults[0].replace(",","%2C") + logThis("Found it") + page = wikia.page("senkulpa",searchResult) + content = page.content.replace(u'\xa0', u' ').split("\n")[0] - images = page.images - if len(images) > 0: - return page.title, content, images[0]+"/revision/latest?path-prefix=da" - else: - return page.title, content, "" + images = page.images + if len(images) > 0: + image = images[len(images)-1]+"/revision/latest?path-prefix=da" + return page.title, content, image + else: + return page.title, content, "" + except: + logThis("Fucked up") + return "", "Sorry. Fucked that one up", "" else: logThis("Couldn't find the page") return "", "Couldn't find page", "" \ No newline at end of file