aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/wikipedia.py
diff options
context:
space:
mode:
authorGravatar Shivansh-007 <[email protected]>2021-05-20 18:30:07 +0530
committerGravatar GitHub <[email protected]>2021-05-20 18:30:07 +0530
commitd032dd1a0e0fb0f866b1b492f917990d66dae55a (patch)
tree0adfc37d1350c7eb0b33ea44d4170a44a017e119 /bot/exts/evergreen/wikipedia.py
parentMerge remote-tracking branch 'origin/feature/command-suggestions' into featur... (diff)
parentMerge pull request #733 from Icebluewolf/http_status_command_randomness (diff)
Merge branch 'main' into feature/command-suggestions
Diffstat (limited to 'bot/exts/evergreen/wikipedia.py')
-rw-r--r--bot/exts/evergreen/wikipedia.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py
index 068c4f43..83937438 100644
--- a/bot/exts/evergreen/wikipedia.py
+++ b/bot/exts/evergreen/wikipedia.py
@@ -20,7 +20,7 @@ WIKI_THUMBNAIL = (
"https://upload.wikimedia.org/wikipedia/en/thumb/8/80/Wikipedia-logo-v2.svg"
"/330px-Wikipedia-logo-v2.svg.png"
)
-WIKI_SNIPPET_REGEX = r'(<!--.*?-->|<[^>]*>)'
+WIKI_SNIPPET_REGEX = r"(<!--.*?-->|<[^>]*>)"
WIKI_SEARCH_RESULT = (
"**[{name}]({url})**\n"
"{description}\n"
@@ -39,18 +39,18 @@ class WikipediaSearch(commands.Cog):
async with self.bot.http_session.get(url=url) as resp:
if resp.status == 200:
raw_data = await resp.json()
- number_of_results = raw_data['query']['searchinfo']['totalhits']
+ number_of_results = raw_data["query"]["searchinfo"]["totalhits"]
if number_of_results:
- results = raw_data['query']['search']
+ results = raw_data["query"]["search"]
lines = []
for article in results:
line = WIKI_SEARCH_RESULT.format(
- name=article['title'],
+ name=article["title"],
description=unescape(
re.sub(
- WIKI_SNIPPET_REGEX, '', article['snippet']
+ WIKI_SNIPPET_REGEX, "", article["snippet"]
)
),
url=f"https://en.wikipedia.org/?curid={article['pageid']}"
@@ -72,7 +72,7 @@ class WikipediaSearch(commands.Cog):
return
@commands.cooldown(1, 10, commands.BucketType.user)
- @commands.command(name="wikipedia", aliases=["wiki"])
+ @commands.command(name="wikipedia", aliases=("wiki",))
async def wikipedia_search_command(self, ctx: commands.Context, *, search: str) -> None:
"""Sends paginated top 10 results of Wikipedia search.."""
contents = await self.wiki_request(ctx.channel, search)
@@ -90,5 +90,5 @@ class WikipediaSearch(commands.Cog):
def setup(bot: Bot) -> None:
- """Wikipedia Cog load."""
+ """Load the WikipediaSearch cog."""
bot.add_cog(WikipediaSearch(bot))