🐛 Fixed wiki command
This commit is contained in:
@ -67,7 +67,7 @@ class MiscCog(commands.Cog):
|
|||||||
|
|
||||||
# Finds a page on the Senkulpa wiki
|
# Finds a page on the Senkulpa wiki
|
||||||
@cog_ext.cog_slash(**params["wiki"])
|
@cog_ext.cog_slash(**params["wiki"])
|
||||||
async def wiki(self, ctx, wikiPage):
|
async def wiki(self, ctx, wikiPage = ""):
|
||||||
await self.bot.other.findWikiPage(ctx, wikiPage)
|
await self.bot.other.findWikiPage(ctx, wikiPage)
|
||||||
|
|
||||||
#Searches for movie and adds it to Bedre Netflix
|
#Searches for movie and adds it to Bedre Netflix
|
||||||
|
@ -4,7 +4,7 @@ import discord # Used in movieFunc
|
|||||||
import datetime # Used in helloFunc
|
import datetime # Used in helloFunc
|
||||||
import urllib # Used in imageFunc
|
import urllib # Used in imageFunc
|
||||||
import lxml # Used in imageFunc
|
import lxml # Used in imageFunc
|
||||||
import wikia # Used in findWikiPage
|
import fandom # Used in findWikiPage
|
||||||
import d20 # Used in rollDice
|
import d20 # Used in rollDice
|
||||||
import ast
|
import ast
|
||||||
from .bedreNetflix import BedreNetflix
|
from .bedreNetflix import BedreNetflix
|
||||||
@ -13,6 +13,9 @@ from .generators import Generators
|
|||||||
|
|
||||||
from utils import cap
|
from utils import cap
|
||||||
|
|
||||||
|
fandom.set_lang("da")
|
||||||
|
fandom.set_wiki("senkulpa")
|
||||||
|
|
||||||
class MyStringifier(d20.MarkdownStringifier):
|
class MyStringifier(d20.MarkdownStringifier):
|
||||||
def _str_expression(self, node):
|
def _str_expression(self, node):
|
||||||
if node.comment == None:
|
if node.comment == None:
|
||||||
@ -136,29 +139,32 @@ class Other():
|
|||||||
# Finds a page from the Senkulpa Wikia
|
# Finds a page from the Senkulpa Wikia
|
||||||
async def findWikiPage(self, ctx, search : str):
|
async def findWikiPage(self, ctx, search : str):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
search = cap(search)
|
|
||||||
foundPage = False
|
foundPage = False
|
||||||
|
|
||||||
self.bot.log("Trying to find wiki page for "+search)
|
if search != "":
|
||||||
wikia.set_lang("da")
|
self.bot.log("Trying to find wiki page for "+search)
|
||||||
searchResults = wikia.search("senkulpa",search)
|
searchResults = fandom.search(search)
|
||||||
if len(searchResults) > 0:
|
if len(searchResults) > 0:
|
||||||
|
foundPage = True
|
||||||
|
searchResult = searchResults[0].replace(",","%2C")
|
||||||
|
else:
|
||||||
|
self.bot.log("Couldn't find the page")
|
||||||
|
await ctx.send("Couldn't find page (error code 1002)")
|
||||||
|
else:
|
||||||
foundPage = True
|
foundPage = True
|
||||||
searchResult = searchResults[0].replace(",","%2C")
|
self.bot.log("Searching for a random page")
|
||||||
|
searchResult = fandom.random()
|
||||||
|
|
||||||
|
if foundPage:
|
||||||
self.bot.log("Found page \""+searchResult+"\"")
|
self.bot.log("Found page \""+searchResult+"\"")
|
||||||
page = wikia.page("senkulpa",searchResult)
|
page = fandom.page(searchResult)
|
||||||
content = page.content.replace(u'\xa0', u' ').split("\n")[0]
|
content = page.summary
|
||||||
|
|
||||||
images = page.images
|
images = page.images
|
||||||
if len(images) > 0:
|
if len(images) > 0:
|
||||||
image = images[len(images)-1]+"/revision/latest?path-prefix=da"
|
image = images[0]
|
||||||
else:
|
else:
|
||||||
image = ""
|
image = ""
|
||||||
else:
|
|
||||||
self.bot.log("Couldn't find the page")
|
|
||||||
await ctx.send("Couldn't find page (error code 1002)")
|
|
||||||
|
|
||||||
if foundPage:
|
|
||||||
self.bot.log("Sending the embedded message",str(ctx.channel_id))
|
self.bot.log("Sending the embedded message",str(ctx.channel_id))
|
||||||
content += f"\n[Læs mere]({page.url})"
|
content += f"\n[Læs mere]({page.url})"
|
||||||
embed = discord.Embed(title = page.title, description = content, colour=0xDEADBF)
|
embed = discord.Embed(title = page.title, description = content, colour=0xDEADBF)
|
||||||
|
@ -1,40 +1,44 @@
|
|||||||
aiohttp==3.6.3
|
aiohttp==3.7.4.post0
|
||||||
|
astroid==2.5.3
|
||||||
async-timeout==3.0.1
|
async-timeout==3.0.1
|
||||||
attrs==20.3.0
|
attrs==20.3.0
|
||||||
beautifulsoup4==4.9.3
|
beautifulsoup4==4.9.3
|
||||||
cachetools==4.2.1
|
cachetools==4.2.1
|
||||||
certifi==2020.12.5
|
certifi==2020.12.5
|
||||||
chardet==3.0.4
|
chardet==4.0.0
|
||||||
d20==1.0.4
|
colorama==0.4.4
|
||||||
discord-py-slash-command @ git+https://github.com/eunwoo1104/discord-py-slash-command.git@3c63f9fe9d186c8492e85c3153aff268f1dd5cae
|
d20==1.1.0
|
||||||
|
discord-py-slash-command==1.1.1
|
||||||
discord.py==1.7.1
|
discord.py==1.7.1
|
||||||
dnspython==2.1.0
|
dnspython==2.1.0
|
||||||
finnhub-python==2.1.0
|
docutils==0.17
|
||||||
|
fandom-py==0.1.6
|
||||||
|
finnhub-python==2.4.0
|
||||||
gitdb==4.0.7
|
gitdb==4.0.7
|
||||||
GitPython==3.1.0
|
GitPython==3.1.14
|
||||||
greenlet==1.0.0
|
greenlet==1.0.0
|
||||||
idna==2.10
|
idna==2.10
|
||||||
IMDbPY==6.8
|
IMDbPY==2020.9.25
|
||||||
inflect==5.3.0
|
isort==5.8.0
|
||||||
jaraco.context==4.0.0
|
jaraco.context==4.0.0
|
||||||
jaraco.itertools==6.0.1
|
|
||||||
lark-parser==0.9.0
|
lark-parser==0.9.0
|
||||||
lxml==4.5.0
|
lazy-object-proxy==1.6.0
|
||||||
|
lxml==4.6.3
|
||||||
|
mccabe==0.6.1
|
||||||
more-itertools==8.7.0
|
more-itertools==8.7.0
|
||||||
multidict==4.7.6
|
multidict==5.1.0
|
||||||
numexpr==2.7.1
|
numpy==1.20.2
|
||||||
numpy==1.18.2
|
Pillow==8.2.0
|
||||||
Pillow==7.1.1
|
pylint==2.7.4
|
||||||
pymongo==3.11.3
|
pymongo==3.11.3
|
||||||
requests==2.25.1
|
requests==2.25.1
|
||||||
six==1.15.0
|
|
||||||
smmap==4.0.0
|
smmap==4.0.0
|
||||||
soupsieve==2.2.1
|
soupsieve==2.2.1
|
||||||
SQLAlchemy==1.4.5
|
SQLAlchemy==1.4.7
|
||||||
|
toml==0.10.2
|
||||||
typing-extensions==3.7.4.3
|
typing-extensions==3.7.4.3
|
||||||
urllib3==1.25.8
|
urllib3==1.26.4
|
||||||
websockets==8.1
|
wolframalpha==5.0.0
|
||||||
wikia==1.4.4
|
wrapt==1.12.1
|
||||||
wolframalpha==4.0.0
|
|
||||||
xmltodict==0.12.0
|
xmltodict==0.12.0
|
||||||
yarl==1.5.1
|
yarl==1.6.3
|
||||||
|
@ -431,7 +431,7 @@
|
|||||||
"name" : "wikiPage",
|
"name" : "wikiPage",
|
||||||
"description" : "The page to find",
|
"description" : "The page to find",
|
||||||
"type" : 3,
|
"type" : 3,
|
||||||
"required" : "true"
|
"required" : "false"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user